Skip to content

Commit 671940f

Browse files
committed
feat(xcom2): Reworked to use Neutwo + Macleod Boynton, Unclamped deferred lighting shaders, Added new FX
1 parent 5e013e9 commit 671940f

File tree

66 files changed

+8866
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+8866
-317
lines changed

src/games/mb-bannerlord/addon.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,7 @@
2323

2424
namespace {
2525

26-
renodx::mods::shader::CustomShaders custom_shaders = {
27-
28-
CustomShaderEntry(0xC1EF5EF0), //output (highest)
29-
CustomShaderEntry(0xB8C92C00), //output (low settings)
30-
CustomShaderEntry(0xF331024C), //postprocess (highest)
31-
CustomShaderEntry(0x675AE1F6), //postprocess (low settings)
32-
CustomShaderEntry(0xF24CD19B), //sky-volumetric (light shafts)
33-
CustomShaderEntry(0xCCD66731), //postprocess (additional)
34-
CustomShaderEntry(0xE691A869), //auto-exposure
35-
CustomShaderEntry(0x66D96DC8), //gtao-computation (small radius)
36-
CustomShaderEntry(0xC2DAA4E8), //gtao-computation2 (large radius)
37-
38-
CustomShaderEntry(0x9D486B77), //deferred-lighting
39-
CustomShaderEntry(0x77B920E0), //deferred-lighting
40-
CustomShaderEntry(0x626C4194), //deferred-lighting
41-
CustomShaderEntry(0xD0C1F854), //deferred-lighting
42-
CustomShaderEntry(0xD2EE110D), //deferred-lighting
43-
CustomShaderEntry(0xE18CA53F), //deferred-lighting
44-
45-
// CustomShaderEntry(0x00000000),
46-
// CustomSwapchainShader(0x00000000),
47-
// BypassShaderEntry(0x00000000),
48-
// __ALL_CUSTOM_SHADERS
49-
};
26+
renodx::mods::shader::CustomShaders custom_shaders = {__ALL_CUSTOM_SHADERS};
5027

5128
ShaderInjectData shader_injection;
5229

@@ -286,6 +263,27 @@ renodx::utils::settings::Settings settings = {
286263
.is_visible = []() { return current_settings_mode >= 1; },
287264
}),
288265

266+
new renodx::utils::settings::Setting({
267+
.key = "FxProbeModulation",
268+
.binding = &shader_injection.custom_probe_modulation,
269+
.default_value = 50.f,
270+
.label = "Probe Modulation",
271+
.section = "Effects",
272+
.tooltip = "Controls how much specular probe reflections are attenuated in dark ambient areas.\n0 = Off, 100 = Maximum attenuation",
273+
.max = 100.f,
274+
.parse = [](float value) { return value * 0.01f; },
275+
}),
276+
277+
new renodx::utils::settings::Setting({
278+
.key = "FxBurleyDiffuse",
279+
.binding = &shader_injection.custom_burley_diffuse,
280+
.value_type = renodx::utils::settings::SettingValueType::BOOLEAN,
281+
.default_value = 1.f,
282+
.label = "Burley Diffuse",
283+
.section = "Effects",
284+
.tooltip = "Replaces the vanilla Lambertian (1/pi) diffuse BRDF with Disney/Burley diffuse for improved roughness-dependent shading",
285+
}),
286+
289287
new renodx::utils::settings::Setting{
290288
.key = "SwapChainCustomColorSpace",
291289
.binding = &shader_injection.swap_chain_custom_color_space,
@@ -359,6 +357,8 @@ void OnPresetOff() {
359357
renodx::utils::settings::UpdateSetting("FxGrainStrength", 0);
360358
renodx::utils::settings::UpdateSetting("FxAutoExposure", 0);
361359
renodx::utils::settings::UpdateSetting("FxSunIntensity", 0);
360+
renodx::utils::settings::UpdateSetting("FxBurleyDiffuse", 0);
361+
renodx::utils::settings::UpdateSetting("FxProbeModulation", 0);
362362
// renodx::utils::settings::UpdateSetting("colorGradeExposure", 1.f);
363363
// renodx::utils::settings::UpdateSetting("colorGradeHighlights", 50.f);
364364
// renodx::utils::settings::UpdateSetting("colorGradeShadows", 50.f);

src/games/mb-bannerlord/deferred-lighting/0x77B920E0.ps_5_0.hlsl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cbuffer cb13 : register(b13) {
33
float custom_ao_debug : packoffset(c9.y);
44
float custom_ao_bypass : packoffset(c9.z);
5+
float custom_probe_modulation : packoffset(c10.x);
6+
float custom_burley_diffuse : packoffset(c10.y);
57
}
68

79
struct t76_t {
@@ -825,6 +827,14 @@ void main(
825827
r12.xyz = r12.xyz + -r13.xyz;
826828
r13.xyz = r0.xxx * r12.xyz + r13.xyz;
827829
}
830+
// Probe luminance modulation: attenuate specular probes in dark ambient areas
831+
if (custom_probe_modulation > 0.0) {
832+
float probeLum = dot(r13.xyz, float3(0.2126729, 0.7151522, 0.0721750));
833+
probeLum = max(probeLum, 0.0);
834+
float K = custom_probe_modulation * 50.0;
835+
float modFactor = probeLum / (probeLum + K);
836+
r0.yzw *= modFactor;
837+
}
828838
r0.x = cmp(0 != cb0[101].x);
829839
if (r0.x != 0) {
830840
r4.w = t28.SampleLevel(s1_s, float2(0.5,0.5), 0).x;
@@ -877,7 +887,20 @@ void main(
877887
r13.xyz = r13.xyz * r1.xxx;
878888
r12.xyz = r13.xyz * r1.www + r12.xyz;
879889
r11.xyz = r11.xyz * r1.www + r12.xyz;
880-
r6.xyz = r11.xyz * r6.xyz;
890+
// Burley (Disney) diffuse BRDF — replaces Lambertian 1/pi
891+
// Uses identity: LdotH^2 = (1 + L.V) / 2 to avoid computing H explicitly
892+
if (custom_burley_diffuse) {
893+
float burley_LdotH2 = 0.5 + 0.5 * dot(cb0[2].xyz, r8.xyz); // (1 + L.V)/2
894+
float burley_NdotV = saturate(dot(r4.xzy, -r8.xyz));
895+
float burley_NdotL = r1.x;
896+
float burley_roughness = r9.x;
897+
float burley_FD90 = 0.5 + 2.0 * burley_roughness * burley_LdotH2;
898+
float burley_sl = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotL, 5.0);
899+
float burley_sv = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotV, 5.0);
900+
r6.xyz = r11.xyz * r6.xyz * (burley_sl * burley_sv);
901+
} else {
902+
r6.xyz = r11.xyz * r6.xyz;
903+
}
881904
r0.yzw = r6.xyz * float3(0.318309873,0.318309873,0.318309873) + r0.yzw;
882905
r3.yzw = -r7.xyz * r3.www + -cb0[2].xyz;
883906
r1.y = dot(r3.yzw, r3.yzw);

src/games/mb-bannerlord/deferred-lighting/0x9D486B77.ps_5_0.hlsl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cbuffer cb13 : register(b13) {
33
float custom_ao_debug : packoffset(c9.y);
44
float custom_ao_bypass : packoffset(c9.z);
5+
float custom_probe_modulation : packoffset(c10.x);
6+
float custom_burley_diffuse : packoffset(c10.y);
57
}
68

79
struct t92_t {
@@ -1613,6 +1615,14 @@ void main(
16131615
r11.xyz = r11.xyz + -r13.xyz;
16141616
r13.xyz = r0.www * r11.xyz + r13.xyz;
16151617
}
1618+
// Probe luminance modulation: attenuate specular probes in dark ambient areas
1619+
if (custom_probe_modulation > 0.0) {
1620+
float probeLum = dot(r13.xyz, float3(0.2126729, 0.7151522, 0.0721750));
1621+
probeLum = max(probeLum, 0.0);
1622+
float K = custom_probe_modulation * 50.0;
1623+
float modFactor = probeLum / (probeLum + K);
1624+
r12.xyz *= modFactor;
1625+
}
16161626
r0.w = cmp(0 != cb0[101].x);
16171627
if (r0.w != 0) {
16181628
r4.z = t28.SampleLevel(s1_s, float2(0.5,0.5), 0).x;
@@ -1645,7 +1655,19 @@ void main(
16451655
r2.y = 1 + -cb0[102].x;
16461656
r5.w = saturate(dot(-cb0[2].xzy, r5.xyz));
16471657
r5.w = max(r5.w, r2.y);
1648-
r11.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1658+
// Burley (Disney) diffuse BRDF — replaces Lambertian 1/pi
1659+
if (custom_burley_diffuse) {
1660+
float burley_LdotH2 = 0.5 + 0.5 * dot(cb0[2].xyz, r3.xyz); // (1 + L.V)/2
1661+
float burley_NdotV = saturate(dot(r3.xzy, r5.xyz));
1662+
float burley_NdotL = saturate(dot(-cb0[2].xzy, r5.xyz));
1663+
float burley_roughness = r2.x;
1664+
float burley_FD90 = 0.5 + 2.0 * burley_roughness * burley_LdotH2;
1665+
float burley_sl = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotL, 5.0);
1666+
float burley_sv = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotV, 5.0);
1667+
r11.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz * (burley_sl * burley_sv);
1668+
} else {
1669+
r11.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1670+
}
16491671
r12.xyz = -cb0[2].xyz + r3.xyz;
16501672
r6.w = dot(r12.xyz, r12.xyz);
16511673
r6.w = rsqrt(r6.w);

src/games/mb-bannerlord/deferred-lighting/0xD0C1F854.ps_5_0.hlsl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cbuffer cb13 : register(b13) {
33
float custom_ao_debug : packoffset(c9.y);
44
float custom_ao_bypass : packoffset(c9.z);
5+
float custom_probe_modulation : packoffset(c10.x);
6+
float custom_burley_diffuse : packoffset(c10.y);
57
}
68

79
struct t92_t {
@@ -1758,6 +1760,14 @@ void main(
17581760
r11.xyz = r11.xyz + -r13.xyz;
17591761
r13.xyz = r0.www * r11.xyz + r13.xyz;
17601762
}
1763+
// Probe luminance modulation: attenuate specular probes in dark ambient areas
1764+
if (custom_probe_modulation > 0.0) {
1765+
float probeLum = dot(r13.xyz, float3(0.2126729, 0.7151522, 0.0721750));
1766+
probeLum = max(probeLum, 0.0);
1767+
float K = custom_probe_modulation * 50.0;
1768+
float modFactor = probeLum / (probeLum + K);
1769+
r12.xyz *= modFactor;
1770+
}
17611771
r0.w = cmp(0 != cb0[101].x);
17621772
if (r0.w != 0) {
17631773
r2.y = t28.SampleLevel(s1_s, float2(0.5,0.5), 0).x;
@@ -1791,7 +1801,19 @@ void main(
17911801
r5.w = 1 + -cb0[102].x;
17921802
r6.w = saturate(dot(-cb0[2].xzy, r5.xyz));
17931803
r6.w = max(r6.w, r5.w);
1794-
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1804+
// Burley (Disney) diffuse BRDF — replaces Lambertian 1/pi
1805+
if (custom_burley_diffuse) {
1806+
float burley_LdotH2 = 0.5 + 0.5 * dot(cb0[2].xyz, r3.xyz); // (1 + L.V)/2
1807+
float burley_NdotV = saturate(dot(r3.xzy, r5.xyz));
1808+
float burley_NdotL = saturate(dot(-cb0[2].xzy, r5.xyz));
1809+
float burley_roughness = r2.x;
1810+
float burley_FD90 = 0.5 + 2.0 * burley_roughness * burley_LdotH2;
1811+
float burley_sl = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotL, 5.0);
1812+
float burley_sv = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotV, 5.0);
1813+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz * (burley_sl * burley_sv);
1814+
} else {
1815+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1816+
}
17951817
r8.xzw = -cb0[2].xyz + r3.xyz;
17961818
r7.w = dot(r8.xzw, r8.xzw);
17971819
r7.w = rsqrt(r7.w);

src/games/mb-bannerlord/deferred-lighting/0xD2EE110D.ps_5_0.hlsl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cbuffer cb13 : register(b13) {
33
float custom_ao_debug : packoffset(c9.y);
44
float custom_ao_bypass : packoffset(c9.z);
5+
float custom_probe_modulation : packoffset(c10.x);
6+
float custom_burley_diffuse : packoffset(c10.y);
57
}
68

79
struct t92_t {
@@ -1774,6 +1776,14 @@ void main(
17741776
r11.xyz = r11.xyz + -r13.xyz;
17751777
r13.xyz = r0.www * r11.xyz + r13.xyz;
17761778
}
1779+
// Probe luminance modulation: attenuate specular probes in dark ambient areas
1780+
if (custom_probe_modulation > 0.0) {
1781+
float probeLum = dot(r13.xyz, float3(0.2126729, 0.7151522, 0.0721750));
1782+
probeLum = max(probeLum, 0.0);
1783+
float K = custom_probe_modulation * 50.0;
1784+
float modFactor = probeLum / (probeLum + K);
1785+
r12.xyz *= modFactor;
1786+
}
17771787
r0.w = cmp(0 != cb0[101].x);
17781788
if (r0.w != 0) {
17791789
r2.y = t28.SampleLevel(s1_s, float2(0.5,0.5), 0).x;
@@ -1807,7 +1817,19 @@ void main(
18071817
r4.z = 1 + -cb0[102].x;
18081818
r4.w = saturate(dot(-cb0[2].xzy, r5.xyz));
18091819
r4.w = max(r4.z, r4.w);
1810-
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1820+
// Burley (Disney) diffuse BRDF — replaces Lambertian 1/pi
1821+
if (custom_burley_diffuse) {
1822+
float burley_LdotH2 = 0.5 + 0.5 * dot(cb0[2].xyz, r3.xyz); // (1 + L.V)/2
1823+
float burley_NdotV = saturate(dot(r3.xzy, r5.xyz));
1824+
float burley_NdotL = saturate(dot(-cb0[2].xzy, r5.xyz));
1825+
float burley_roughness = r2.x;
1826+
float burley_FD90 = 0.5 + 2.0 * burley_roughness * burley_LdotH2;
1827+
float burley_sl = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotL, 5.0);
1828+
float burley_sv = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotV, 5.0);
1829+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz * (burley_sl * burley_sv);
1830+
} else {
1831+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1832+
}
18111833
r11.xyz = -cb0[2].xyz + r3.xyz;
18121834
r5.w = dot(r11.xyz, r11.xyz);
18131835
r5.w = rsqrt(r5.w);

src/games/mb-bannerlord/deferred-lighting/0xE18CA53F.ps_5_0.hlsl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
cbuffer cb13 : register(b13) {
33
float custom_ao_debug : packoffset(c9.y);
44
float custom_ao_bypass : packoffset(c9.z);
5+
float custom_probe_modulation : packoffset(c10.x);
6+
float custom_burley_diffuse : packoffset(c10.y);
57
}
68

79
struct t92_t {
@@ -1770,6 +1772,14 @@ void main(
17701772
r11.xyz = r11.xyz + -r13.xyz;
17711773
r13.xyz = r0.www * r11.xyz + r13.xyz;
17721774
}
1775+
// Probe luminance modulation: attenuate specular probes in dark ambient areas
1776+
if (custom_probe_modulation > 0.0) {
1777+
float probeLum = dot(r13.xyz, float3(0.2126729, 0.7151522, 0.0721750));
1778+
probeLum = max(probeLum, 0.0);
1779+
float K = custom_probe_modulation * 50.0;
1780+
float modFactor = probeLum / (probeLum + K);
1781+
r12.xyz *= modFactor;
1782+
}
17731783
r0.w = cmp(0 != cb0[101].x);
17741784
if (r0.w != 0) {
17751785
r2.y = t28.SampleLevel(s1_s, float2(0.5,0.5), 0).x;
@@ -1803,7 +1813,19 @@ void main(
18031813
r5.w = 1 + -cb0[102].x;
18041814
r6.w = saturate(dot(-cb0[2].xzy, r5.xyz));
18051815
r6.w = max(r6.w, r5.w);
1806-
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1816+
// Burley (Disney) diffuse BRDF — replaces Lambertian 1/pi
1817+
if (custom_burley_diffuse) {
1818+
float burley_LdotH2 = 0.5 + 0.5 * dot(cb0[2].xyz, r3.xyz); // (1 + L.V)/2
1819+
float burley_NdotV = saturate(dot(r3.xzy, r5.xyz));
1820+
float burley_NdotL = saturate(dot(-cb0[2].xzy, r5.xyz));
1821+
float burley_roughness = r2.x;
1822+
float burley_FD90 = 0.5 + 2.0 * burley_roughness * burley_LdotH2;
1823+
float burley_sl = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotL, 5.0);
1824+
float burley_sv = 1.0 + (burley_FD90 - 1.0) * pow(1.0 - burley_NdotV, 5.0);
1825+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz * (burley_sl * burley_sv);
1826+
} else {
1827+
r7.xyz = float3(0.318309873,0.318309873,0.318309873) * r7.xyz;
1828+
}
18071829
r8.xzw = -cb0[2].xyz + r3.xyz;
18081830
r7.w = dot(r8.xzw, r8.xzw);
18091831
r7.w = rsqrt(r7.w);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// ---- Created with 3Dmigoto v1.4.1 on Thu Feb 19 09:36:59 2026
2+
Texture2D<float4> t16 : register(t16);
3+
4+
SamplerState s0_s : register(s0);
5+
6+
cbuffer cb0 : register(b0)
7+
{
8+
float4 cb0[106];
9+
}
10+
11+
12+
13+
14+
// 3Dmigoto declarations
15+
#define cmp -
16+
17+
18+
void main(
19+
float4 v0 : SV_POSITION0,
20+
float4 v1 : COLOR0,
21+
float2 v2 : TEXCOORD0,
22+
out float4 o0 : SV_TARGET0)
23+
{
24+
float4 r0,r1;
25+
uint4 bitmask, uiDest;
26+
float4 fDest;
27+
28+
r0.x = 1 + -v2.y;
29+
r0.x = r0.x * 2 + -1;
30+
r0.xyzw = cb0[44].xyzw * r0.xxxx;
31+
r1.x = v2.x * 2 + -1;
32+
r0.xyzw = cb0[43].xyzw * r1.xxxx + r0.xyzw;
33+
r1.xy = cb0[105].xy * v2.xy;
34+
r1.x = t16.Sample(s0_s, r1.xy).x;
35+
r0.xyzw = cb0[45].xyzw * r1.xxxx + r0.xyzw;
36+
r0.xyzw = cb0[46].xyzw + r0.xyzw;
37+
r0.xyz = r0.xyz / r0.www;
38+
r1.yzw = cb0[20].xyw * r0.yyy;
39+
r0.xyw = cb0[19].xyw * r0.xxx + r1.yzw;
40+
r0.xyz = cb0[21].xyw * r0.zzz + r0.xyw;
41+
r0.xyz = cb0[22].xyw + r0.xyz;
42+
r0.xy = r0.xy / r0.zz;
43+
r0.xy = r0.xy * float2(0.5,0.5) + float2(0.5,0.5);
44+
r0.z = 1 + -r0.y;
45+
r0.yw = r0.xz * float2(2,2) + float2(-1,-1);
46+
r1.yzw = cb0[48].xyw * -r0.www;
47+
r1.yzw = cb0[47].xyw * r0.yyy + r1.yzw;
48+
r1.xyz = cb0[49].xyw * r1.xxx + r1.yzw;
49+
r1.xyz = cb0[50].xyw + r1.xyz;
50+
r0.yw = r1.xy / r1.zz;
51+
r1.xy = r0.yw * float2(0.5,0.5) + float2(0.5,0.5);
52+
r1.z = 1 + -r1.y;
53+
o0.xy = -r1.xz + r0.xz;
54+
o0.zw = float2(0,0);
55+
return;
56+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ---- Created with 3Dmigoto v1.4.1 on Thu Feb 19 09:36:59 2026
2+
Texture2D<float4> t1 : register(t1);
3+
4+
Texture2D<float4> t0 : register(t0);
5+
6+
SamplerState s1_s : register(s1);
7+
8+
9+
10+
11+
// 3Dmigoto declarations
12+
#define cmp -
13+
14+
15+
void main(
16+
float4 v0 : SV_POSITION0,
17+
float4 v1 : COLOR0,
18+
float2 v2 : TEXCOORD0,
19+
out float4 o0 : SV_TARGET0)
20+
{
21+
float4 r0;
22+
uint4 bitmask, uiDest;
23+
float4 fDest;
24+
25+
r0.x = t0.Sample(s1_s, v2.xy).x;
26+
r0.y = t1.Sample(s1_s, v2.xy).x;
27+
o0.xyzw = min(r0.yyyy, r0.xxxx);
28+
return;
29+
}

0 commit comments

Comments
 (0)