Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a916c4f
Shadow of War: HDR and more
XgarhontX Jul 19, 2026
c25ff94
Shadow of War: Include everything and GameCBuffers
XgarhontX Jul 20, 2026
289fac0
Shadow of War: Del unused shaders
XgarhontX Jul 20, 2026
6de25a8
Shadow of War: include a bunch of libs
XgarhontX Jul 20, 2026
4f2e9ce
Shadow of War: Clean main
XgarhontX Jul 20, 2026
33f5d24
Shadow of War: uses global include RCAS
XgarhontX Jul 20, 2026
c8183bc
Shadow of War: Reworded SR ImGui Section
XgarhontX Jul 20, 2026
43f1649
Shadow of War: Don't exec SR code if off. Reduced Namespaces.
XgarhontX Jul 20, 2026
a0359a7
Shadow of War: fixes
XgarhontX Jul 20, 2026
fcc9acc
Shadow of War: DISABLE_AUTO_DEBUGGER 1
XgarhontX Jul 20, 2026
c4b1935
Shadow of War: Fixed unreadable text color
XgarhontX Jul 20, 2026
57c91e7
Shadow of War: Removed duplicated shader
XgarhontX Jul 20, 2026
a35e797
Shadow of War: DLSS Jitter History (DEVELOPMENT)
XgarhontX Jul 20, 2026
ab5c53b
Shadow of War: Fixed ImGui ID pushing
XgarhontX Jul 20, 2026
e76a983
Shadow of War: Reword user settings
XgarhontX Jul 20, 2026
60eebf4
Shadow of War: Cleaned Shaders
XgarhontX Jul 21, 2026
ce6e0e3
Shadow of War: Fixed edge cases for rolloff ext
XgarhontX Jul 21, 2026
73e2599
Shadow of War: exposed Retuned Fire settings
XgarhontX Jul 21, 2026
0795776
Shadow of War: SR in Photo Mode (when TAA w/o MVs)
XgarhontX Jul 21, 2026
7ebcc11
Shadow of War: Exposed Mip LOD bias for user to boost past SR recomme…
XgarhontX Jul 21, 2026
007e9c7
Shadow of War: removed Photo Mode warning
XgarhontX Jul 21, 2026
e521a2e
Shadow of War: typo
XgarhontX Jul 21, 2026
28b127b
Shadow of War: Re-added the CopyResource() fix
XgarhontX Jul 21, 2026
cc372f5
Shadow of War: No more UAV access for SR. Pass in dummy resource for …
XgarhontX Jul 21, 2026
89d569a
Shadow of War: draw_data.reset
XgarhontX Jul 21, 2026
f0bd150
Shadow of War: typo
XgarhontX Jul 21, 2026
3a12412
Shadow of War: JitterHistory shows raw from CB
XgarhontX Jul 21, 2026
1897e9c
Shadow of War: tonemap safer which fixed TAA black
XgarhontX Jul 21, 2026
bae964a
Shadow of War: Removed "needs testing" comment for jitter since it wo…
XgarhontX Jul 22, 2026
348809f
Shadow of War: Sampler upgrades default off again. Tooltip to warn user.
XgarhontX Jul 22, 2026
9a9ab6b
Shadow of War: force DEVELOPMENT Shader Define off
XgarhontX Jul 22, 2026
a688195
Shadow of War: retuned Fire Retuning
XgarhontX Jul 22, 2026
31279ce
Shadow of War: FSR
XgarhontX Jul 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Shaders/Middle-earth Shadow of War/Includes/ColorGrade.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "../Includes/Color.hlsl"

//from RenoDX clshortfuse
float RenoDX_Contrast(float x, float contrast, float mid_gray = 0.18f) {
return pow(max(0, x / mid_gray), contrast) * mid_gray;
}
float3 RenoDX_Contrast(float3 x, float contrast, float mid_gray = 0.18f) {
return pow(max(0, x / mid_gray), contrast) * mid_gray;
}
float RenoDX_Shadows(float x, float shadows, float mid_gray) {
float value;
if (shadows > 1.f) {
value = max(x, x * (1.f + (x * mid_gray / pow(x / mid_gray, shadows))));
} else if (shadows < 1.f) {
value = clamp(x * (1.f - (x * mid_gray / pow(x / mid_gray, 2.f - shadows))), 0.f , x);
} else {
value = x;
}
return value;
}
float RenoDX_Highlights(float x, float highlights, float mid_gray) {
float value;
if (highlights > 1.f) {
value = max(x, lerp(x, mid_gray * pow(x / mid_gray, highlights), x));
} else if (highlights < 1.f) {
value = min(x, x / (1.f + mid_gray * pow(x / mid_gray, 2.f - highlights) - x));
} else {
value = x;
}
return value;
}

float3 RenoDX_ColorGrade(
float3 x,
float contrast = 1, float contrast_mid = 0.18f,
float highlights = 1, float highlights_mid = 0.18f,
float shadows = 1, float shadows_mid = 0.18f,
float saturation = 1,
uint colorspace = CS_DEFAULT,
bool clampCs = false
) {
float l = GetLuminance(x, colorspace);
float lOrig = l;
if (l <= 0) return 0; //0 is redundant and div 0

//Luminance Grading
l = RenoDX_Contrast(l, contrast, contrast_mid);
l = RenoDX_Highlights(l, highlights, highlights_mid);
l = RenoDX_Shadows(l, shadows, shadows_mid);
x *= l / lOrig;

//Saturation
if (saturation != 1.f) x = Saturation(x, saturation, colorspace);

//Clamp
if (clampCs) x = max(0, x);

return x;
}
10 changes: 9 additions & 1 deletion Shaders/Middle-earth Shadow of War/Includes/Common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
// Global common
#include "../../Includes/Common.hlsl"
// Game specific settings
#include "Settings.hlsl"
#include "Settings.hlsl"

#define GS LumaSettings.GameSettings

#define HDR_ENABLED LumaSettings.DisplayMode == 1
#define HDR_PEAK PeakWhiteNits / GamePaperWhiteNits
#define HDR_INTSCALING GamePaperWhiteNits / UIPaperWhiteNits
// #define HDR_SHOULDERSTART GS.TonemapperRolloffStart / GamePaperWhiteNits
// #define HDR_MAXEXPECTED GS.TonemapperMaxExpected / GamePaperWhiteNits
29 changes: 15 additions & 14 deletions Shaders/Middle-earth Shadow of War/Includes/GameCBuffers.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
#define LUMA_GAME_CB_STRUCTS

#ifdef __cplusplus
// This include is needed to allow reading shader types from c++.
#include "../../../Source/Core/includes/shader_types.h"
#endif

// Mirrors c++ name spaces.
namespace CB
{
// Define the game specific cbuffer settings here. They don't need 4 bytes alignment.
struct LumaGameSettings
{
float GameSetting01;
uint GameSetting02;
};

// Define the game specific cbuffer (instance/pass) data here
struct LumaGameData
{
float Dummy; // hlsl doesn't support empty structs
};
struct LumaGameSettings
{
float WhiteClip;
float BlowoutCorrection;
float RetunedFirePeak;
float RetunedFireBoost;
float GodRays;
float Bloom;
float RCAS;
};

struct LumaGameData
{
float Dummy;
};
}

#endif // LUMA_GAME_CB_STRUCTS
13 changes: 0 additions & 13 deletions Shaders/Middle-earth Shadow of War/Includes/Settings.hlsl

This file was deleted.

195 changes: 195 additions & 0 deletions Shaders/Middle-earth Shadow of War/Includes/ictcp_portable.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
namespace renodx {
namespace color {

namespace pq {
static const float M1 = 2610.f / 16384.f; // 0.1593017578125f;
static const float M2 = 128.f * (2523.f / 4096.f); // 78.84375f;
static const float C1 = 3424.f / 4096.f; // 0.8359375f;
static const float C2 = 32.f * (2413.f / 4096.f); // 18.8515625f;
static const float C3 = 32.f * (2392.f / 4096.f); // 18.6875f;

float Encode(float color, float scaling = 10000.f) {
color *= (scaling / 10000.f);
float y_m1 = pow(color, M1);
return pow((C1 + C2 * y_m1) / (1.f + C3 * y_m1), M2);
}

float3 Encode(float3 color, float scaling = 10000.f) {
color *= (scaling / 10000.f);
float3 y_m1 = pow(color, M1);
return pow((C1 + C2 * y_m1) / (1.f + C3 * y_m1), M2);
}

float Decode(float color, float scaling = 10000.f) {
float e_m12 = pow(color, 1.f / M2);
float out_color = pow(max(0, e_m12 - C1) / (C2 - C3 * e_m12), 1.f / M1);
return out_color * (10000.f / scaling);
}

float3 Decode(float3 color, float scaling = 10000.f) {
float3 e_m12 = pow(color, 1.f / M2);
float3 out_color = pow(max(0, e_m12 - C1) / (C2 - C3 * e_m12), 1.f / M1);
return out_color * (10000.f / scaling);
}

float3 EncodeSafe(float3 color, float scaling = 10000.f) {
return Encode(max(0, color), scaling);
}

float3 DecodeSafe(float3 color, float scaling = 10000.f) {
return Decode(max(0, color), scaling);
}

} // namespace pq

// According to Dolby
static const float3x3 XYZ_D65_TO_HUNT_POINTER_ESTEVEZ_LMS_MAT = float3x3(
+0.4002f, 0.7076f, -0.0808f,
-0.2263f, 1.1653f, +0.0457f,
+0.0000f, 0.0000f, +0.9182f);

float3x3 Invert3x3(float3x3 m) {
float a = m[0][0], b = m[0][1], c = m[0][2];
float d = m[1][0], e = m[1][1], f = m[1][2];
float g = m[2][0], h = m[2][1], i = m[2][2];

float A = (e * i - f * h);
float B = -(d * i - f * g);
float C = (d * h - e * g);
float D = -(b * i - c * h);
float E = (a * i - c * g);
float F = -(a * h - b * g);
float G = (b * f - c * e);
float H = -(a * f - c * d);
float I = (a * e - b * d);

float det = a * A + b * B + c * C;
float invDet = det > 0 ? 1.0 / det : 0.0;

return float3x3(
A, D, G,
B, E, H,
C, F, I)
* invDet;
}

static const float3x3 PLMS_TO_IPT_MAT = float3x3(
0.4f, 0.4f, 0.2f,
4.4550f, -4.8510f, 0.3960f,
0.8056f, 0.3572f, -1.1628f);

static const float3x3 BT709_TO_XYZ_MAT = float3x3(
0.4123907993f, 0.3575843394f, 0.1804807884f,
0.2126390059f, 0.7151686788f, 0.0721923154f,
0.0193308187f, 0.1191947798f, 0.9505321522f);

static const float3x3 BT2020_TO_XYZ_MAT = float3x3(
0.6369580483f, 0.1446169036f, 0.1688809752f,
0.2627002120f, 0.6779980715f, 0.0593017165f,
0.0000000000f, 0.0280726930f, 1.0609850577f);

namespace ictcp {
// https://professional.dolby.com/siteassets/pdfs/ictcp_dolbywhitepaper_v071.pdf

static const float3x3 XYZ_TO_ICTCP_LMS_MAT = float3x3(
0.359168797f, 0.697604775f, -0.0357883982f,
-0.192186400f, 1.10039842f, 0.0755404010f,
0.00695759989f, 0.0749168023f, 0.843357980f);

static const float3x3 ICTCP_LMS_TO_XYZ_MAT = float3x3(
2.07036161f, -1.32659053f, 0.206681042f,
0.364990383f, 0.680468797f, -0.0454616732f,
-0.0495028905f, -0.0495028905f, 1.18806946f);

static const float3x3 BT709_TO_ICTCP_LMS_MAT = float3x3(
0.295764088f, 0.623072445f, 0.0811667516f,
0.156191974f, 0.727251648f, 0.116557933f,
0.0351022854f, 0.156589955f, 0.808302998f);

static const float3x3 ICTCP_LMS_TO_BT709_MAT = float3x3(
6.17353248f, -5.32089900f, 0.147354885f,
-1.32403194f, 2.56026983f, -0.236238613f,
-0.0115983877f, -0.264921456f, 1.27652633f);

static const float CROSSTALK = 0.04f;
static const float IPT_OPTIMIZATION = 1.0f;

static const float3x3 CROSSTALK_MAT = float3x3(
1.0f - (2 * CROSSTALK), CROSSTALK, CROSSTALK,
CROSSTALK, 1.0f - (2 * CROSSTALK), CROSSTALK,
CROSSTALK, CROSSTALK, 1.0f - (2 * CROSSTALK));

static const float3x3 XYZ_TO_DOLBY_LMS_MAT = mul(XYZ_D65_TO_HUNT_POINTER_ESTEVEZ_LMS_MAT, CROSSTALK_MAT);

static const float3x3 PLMS_TO_IPT_OPTIMIZED_MAT = float3x3(
lerp(PLMS_TO_IPT_MAT[0], float3(0.5f, 0.5f, 0.0f), IPT_OPTIMIZATION),
PLMS_TO_IPT_MAT[1],
PLMS_TO_IPT_MAT[2]);

static const float VECTORSCOPE_DEGREES = 65.f;
static const float ROTATION_POINT = VECTORSCOPE_DEGREES * 3.14159265358979323846f / 180.f;

static const float3x3 IPT_ROTATION_MAT = float3x3(
1.f, 0, 0.f,
0, cos(ROTATION_POINT), -sin(ROTATION_POINT),
0, sin(ROTATION_POINT), cos(ROTATION_POINT));

static const float SCALE_FACTOR = 1.4f;
static const float3x3 IPT_SCALE_MAT = float3x3(
1.0f, 1.0f, 1.0f,
SCALE_FACTOR, SCALE_FACTOR, SCALE_FACTOR,
1.0f, 1.0f, 1.0f);

static const float3x3 PLMS_TO_ICTCP_MAT = mul(IPT_ROTATION_MAT, PLMS_TO_IPT_OPTIMIZED_MAT) * IPT_SCALE_MAT;

namespace internal {
float3 BT709(float3 bt709_color, float scaling = 100.f) {
float3 lms = mul(mul(XYZ_TO_DOLBY_LMS_MAT, BT709_TO_XYZ_MAT), bt709_color);
float3 plms = pq::Encode(max(0, lms), scaling);
float3 ictcp_color = mul(PLMS_TO_ICTCP_MAT, plms);
return ictcp_color;
}
float3 BT2020(float3 bt2020_color, float scaling = 100.f) {
float3 lms = mul(mul(XYZ_TO_DOLBY_LMS_MAT, BT2020_TO_XYZ_MAT), bt2020_color);
float3 plms = pq::Encode(max(0, lms), scaling);
float3 ictcp_color = mul(PLMS_TO_ICTCP_MAT, plms);
return ictcp_color;
}
float3 ICtCpBT709(float3 ictcp_color, float scaling = 100.f) {
float3 plms_color = mul(Invert3x3(ictcp::PLMS_TO_ICTCP_MAT), ictcp_color);
float3 lms_color = pq::Decode(plms_color, scaling);
float3 bt709_color = mul(
mul(
Invert3x3(BT709_TO_XYZ_MAT),
Invert3x3(ictcp::XYZ_TO_DOLBY_LMS_MAT)),
lms_color);
return bt709_color;
}
float3 ICtCpBT2020(float3 ictcp_color, float scaling = 100.f) {
float3 plms_color = mul(Invert3x3(ictcp::PLMS_TO_ICTCP_MAT), ictcp_color);
float3 lms_color = pq::Decode(plms_color, scaling);
float3 bt709_color = mul(
mul(
Invert3x3(BT2020_TO_XYZ_MAT),
Invert3x3(ictcp::XYZ_TO_DOLBY_LMS_MAT)),
lms_color);
return bt709_color;
}
}

float3 To(float3 rgb, uint colorSpace)
{
if (colorSpace == 1) return internal::BT2020(rgb);
return internal::BT709(rgb);
}

float3 From(float3 ictcp_color, uint colorSpace)
{
if (colorSpace == 1) return internal::ICtCpBT2020(ictcp_color);
return internal::ICtCpBT709(ictcp_color);
}


}
}
}
Loading
Loading