diff --git a/Mad Max/ShaderFixes/cfe4a25b2677c39b-ps_replace.txt b/Mad Max/ShaderFixes/cfe4a25b2677c39b-ps_replace.txt index ac2137516..b40ce9001 100644 --- a/Mad Max/ShaderFixes/cfe4a25b2677c39b-ps_replace.txt +++ b/Mad Max/ShaderFixes/cfe4a25b2677c39b-ps_replace.txt @@ -1,3 +1,5 @@ +// Lens flare +// VS e9849e745227d124 cbuffer GlobalConstants : register(b0) { @@ -33,21 +35,60 @@ void main( float4 fDest; r0.xy = saturate(InstanceConsts[0].xy); + +float4 stereo = StereoParams.Load(0); +// Values from frame analysis of other shaders that sample depth buffer and +// scale to world Z: +float depth = 1 / (InstanceConsts[0].z * 9.9999752 + 0.000025); +float correction = stereo.x * (depth - stereo.y) / depth / 2; + + +//// Debugging, show original depth buffer sample location in red: +//if (abs(v0.x/1920 - r0.x) < 0.01) { +// o0 = float4(1,0,0,1); +// return; +//} + +r0.x += correction; + +//// Debugging, show adjusted depth buffer sample location in green: +//if (abs(v0.x/1920 - r0.x) < 0.01) { +// o0 = float4(0,1,0,1); +// return; +//} + + r0.x = DepthTexture.Sample(DepthTexture_s, r0.xy).x; r0.x = r0.x < InstanceConsts[0].z; r0.x = r0.x ? 0.500000 : 0; r1.xyzw = saturate(Globals[8].zwzw * float4(-3,3.5,3.5,6) + InstanceConsts[0].xyxy); + +r1.x += correction; +r1.z += correction; + r0.y = DepthTexture.Sample(DepthTexture_s, r1.xy).x; r0.z = DepthTexture.Sample(DepthTexture_s, r1.zw).x; r0.yz = r0.yz < InstanceConsts[0].zz; - r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + +// Decompiler bug misinterpreted 0x3e000000: + // r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + r0.yz = r0.yz ? float2(0.125, 0.125) : 0; + r0.x = r0.x + r0.y; r0.x = r0.x + r0.z; r1.xyzw = saturate(Globals[8].zwzw * float4(-5,-3.5,3,-3) + InstanceConsts[0].xyxy); + +r1.x += correction; +r1.z += correction; + r0.y = DepthTexture.Sample(DepthTexture_s, r1.xy).x; r0.z = DepthTexture.Sample(DepthTexture_s, r1.zw).x; r0.yz = r0.yz < InstanceConsts[0].zz; - r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + +// Decompiler bug misinterpreted 0x3e000000: + // r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + r0.yz = r0.yz ? float2(0.125, 0.125) : 0; + r0.x = r0.x + r0.y; r0.x = r0.x + r0.z; r0.y = SkyMaskB.Sample(SkyMaskB_s, InstanceConsts[1].xyz).y; diff --git a/Mad Max/ShaderFixes/d6160e64bc5d9be7-ps_replace.txt b/Mad Max/ShaderFixes/d6160e64bc5d9be7-ps_replace.txt index 2e17d332d..34e282559 100644 --- a/Mad Max/ShaderFixes/d6160e64bc5d9be7-ps_replace.txt +++ b/Mad Max/ShaderFixes/d6160e64bc5d9be7-ps_replace.txt @@ -1,3 +1,5 @@ +// Bloom around lights +// VS e9849e745227d124 cbuffer GlobalConstants : register(b0) { @@ -29,21 +31,59 @@ void main( float4 fDest; r0.xy = saturate(InstanceConsts[0].xy); + +float4 stereo = StereoParams.Load(0); +// Values from frame analysis of other shaders that sample depth buffer and +// scale to world Z: +float depth = 1 / (InstanceConsts[0].z * 9.9999752 + 0.000025); +float correction = stereo.x * (depth - stereo.y) / depth / 2; + + +// // Debugging, show original depth buffer sample location in red: +// if (abs(v0.x/1920 - r0.x) < 0.01) { +// o0 = float4(1,0,0,1); +// return; +// } + +r0.x += correction; + +// // Debugging, show adjusted depth buffer sample location in green: +// if (abs(v0.x/1920 - r0.x) < 0.01) { +// o0 = float4(0,1,0,1); +// return; +// } + r0.x = DepthTexture.Sample(DepthTexture_s, r0.xy).x; r0.x = r0.x < InstanceConsts[0].z; r0.x = r0.x ? 0.500000 : 0; r1.xyzw = saturate(Globals[8].zwzw * float4(-3,3.5,3.5,6) + InstanceConsts[0].xyxy); + +r1.x += correction; +r1.z += correction; + r0.y = DepthTexture.Sample(DepthTexture_s, r1.xy).x; r0.z = DepthTexture.Sample(DepthTexture_s, r1.zw).x; r0.yz = r0.yz < InstanceConsts[0].zz; - r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + +// Decompiler bug misinterpreted 0x3e000000: + //r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + r0.yz = r0.yz ? float2(0.125, 0.125) : 0; + r0.x = r0.x + r0.y; r0.x = r0.x + r0.z; r1.xyzw = saturate(Globals[8].zwzw * float4(-5,-3.5,3,-3) + InstanceConsts[0].xyxy); + +r1.x += correction; +r1.z += correction; + r0.y = DepthTexture.Sample(DepthTexture_s, r1.xy).x; r0.z = DepthTexture.Sample(DepthTexture_s, r1.zw).x; r0.yz = r0.yz < InstanceConsts[0].zz; - r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + +// Decompiler bug misinterpreted 0x3e000000: + // r0.yz = r0.yz ? float2(1.04018739e+009,1.04018739e+009) : 0; + r0.yz = r0.yz ? float2(0.125, 0.125) : 0; + r0.x = r0.x + r0.y; r0.x = r0.x + r0.z; r1.xyzw = DiffuseTexture.Sample(DiffuseTexture_s, v1.xy).xyzw;