Black Desert Online 3D fix..
  10 / 11    
Yeah you are probably at least better to post in the shader school thread if you haven't than here as the people in the know are probably more likely to see it. Theres a still a fair bit of lighting off in this fix as well, although I assume thats even more of a complex issue than the shadows. =x
Yeah you are probably at least better to post in the shader school thread if you haven't than here as the people in the know are probably more likely to see it. Theres a still a fair bit of lighting off in this fix as well, although I assume thats even more of a complex issue than the shadows. =x

i7-4790K CPU 4.8Ghz stable overclock.
16 GB RAM Corsair
EVGA 1080TI SLI
Samsung SSD 840Pro
ASUS Z97-WS
3D Surround ASUS Rog Swift PG278Q(R), 2x PG278Q (yes it works)
Obutto R3volution.
Windows 10 pro 64x (Windows 7 Dual boot)

Posted 05/06/2017 09:31 AM   
Well if you can get a screenshot of what you see that is wrong I would appreciate it.. I did tonight see some issues withe the cliffs near the shoreline it had sort of a one eye effect.. Really wierd and I did find a shader for it but it seemed to have broken some other things so that was definetley problay part of the problem you are seeing..
Well if you can get a screenshot of what you see that is wrong I would appreciate it..

I did tonight see some issues withe the cliffs near the shoreline it had sort of a one eye effect..

Really wierd and I did find a shader for it but it seemed to have broken some other things so that was definetley problay part of the problem you are seeing..

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/06/2017 09:58 AM   
Since you requested I take a look here, I have. Looking at the code you linked to, it seems pretty standard enough that I'm pretty sure I can offer what the solution is. First off, you will need to include DSS's matrix.hlsl file in the ShaderFixes folder. You can find that file on his Github, or if you look you'll find it in most of my fixes. Here's a "dumbed down" version that is a little easier to understand. I've included comments to try to help with understanding what's going on. Make particular note at the inclusions on lines 157-158, 170-183, & 238-256: [code]// Shadows in game PS.. // ---- Created with 3Dmigoto v1.2.56 on Fri May 05 23:33:28 2017 cbuffer _Globals : register(b0) { float4x4 matFarCloudShadowProjectionTexScale : packoffset(c0); float4 vecInvScreenSize : packoffset(c4); float4x4 matViewProjection : packoffset(c5); float4x4 matViewProjectionTexScale : packoffset(c9); float4 vecCurrentPosition : packoffset(c13); float4 vecFarTerrainHeightConst : packoffset(c14); float3 vecFaceBonePosition : packoffset(c15); float fLongtermAOAdder : packoffset(c15.w); float fTerrainLongtermHeight : packoffset(c16) = {2000}; bool isLongTermAO : packoffset(c16.y); bool isSSAO : packoffset(c16.z); bool isSSAOReflect : packoffset(c16.w); bool isShadow : packoffset(c17); bool isSelfShadow : packoffset(c17.y); bool isRenderTerrainLongtermShadow : packoffset(c17.z); bool isGICalc : packoffset(c17.w); } cbuffer outdoorScatteringConst : register(b2) { float4 vecSunColorConst : packoffset(c0); float4 vecSunGlareColorConst : packoffset(c1); float4 vecHorizon0ColorConst : packoffset(c2); float4 vecHorizon1ColorConst : packoffset(c3); float4 vecSkyBaseColorConst : packoffset(c4); float4 vecExtinctionColorConst : packoffset(c5); float4 vecReighColorConst : packoffset(c6); float4 vecSunScatterColorConst : packoffset(c7); float4 vecAmbientColorConst[2] : packoffset(c8); float4 vecAmbientOcclusionColorConst : packoffset(c10); float4 vecDeepAOColorConst : packoffset(c11); float4 vecSkinAmbientColorConst : packoffset(c12); float4 vecHairAmbientColorConst : packoffset(c13); float4 vecEffectAmbientColorAlphaConst : packoffset(c14); float4 vecEffectAmbientColorConst : packoffset(c15); float4 vecEffectAmbientColorHit : packoffset(c16); float4 vecEffectAmbientColorHitAlpha : packoffset(c17); float3 vecSunDirection : packoffset(c18); float fSeaHeightConst : packoffset(c18.w); float3 vecMoonDirection : packoffset(c19); float IndoorRateRegion : packoffset(c19.w); float fSunScatterExpConst : packoffset(c20); float fSunGlareExpConst : packoffset(c20.y); float fSunExpConst : packoffset(c20.z); float fScatterDistanceFalloffConst : packoffset(c20.w); float fMieDistanceFalloffConst : packoffset(c21); float fMieHeightConst : packoffset(c21.y); float fReighDistanceFalloffConst : packoffset(c21.z); float fEnvIntensityConst : packoffset(c21.w); float fHorizonColorExp0Const : packoffset(c22); float fHorizonColorExp1Const : packoffset(c22.y); float fCharacterLightMultiply : packoffset(c22.z); float fCharacterLightMultiply2 : packoffset(c22.w); float RainAmount : packoffset(c23); float AirTemperature : packoffset(c23.y); float AirTemperatureForParticle : packoffset(c23.z); float IndoorRateRoof : packoffset(c23.w); float3 vecLightDirection : packoffset(c24); float fCloudLayer0Const : packoffset(c24.w); float fCloudLayer1Const : packoffset(c25); float fCloudLayer2Const : packoffset(c25.y); float fCloudLayer3Const : packoffset(c25.z); float fCloudLayer4Const : packoffset(c25.w); float fCloudLayer5Const : packoffset(c26); float fCloudLayer6Const : packoffset(c26.y); float fCloudLayer7Const : packoffset(c26.z); float fCloudLayer8Const : packoffset(c26.w); float fCloudLayer9Const : packoffset(c27); float fCloudLayer10Const : packoffset(c27.y); float fCloudLayer11Const : packoffset(c27.z); float fCloudLayer12Const : packoffset(c27.w); float4 fShaderTest : packoffset(c28) = {1,1,1,1}; float4 vecCloudColorConst : packoffset(c29); float3 vecColorMultiply : packoffset(c30); float fBrightnessMultiply : packoffset(c30.w); } cbuffer shadowConst : register(b3) { row_major float4x4 matShadowProjectionTexScale0 : packoffset(c0); row_major float4x4 matShadowProjectionTexScale1 : packoffset(c4); row_major float4x4 matShadowProjectionTexScale2 : packoffset(c8); row_major float4x4 matShadowProjectionTexScale3 : packoffset(c12); float4 vecShadowViewPosition0 : packoffset(c16); float4 vecShadowViewPosition1 : packoffset(c17); float4 vecShadowViewPosition2 : packoffset(c18); float4 vecShadowViewPosition3 : packoffset(c19); float fShadowmapSizeNear : packoffset(c20); float fShadowmapSizeFar : packoffset(c20.y); float fInvShadowmapSizeNear : packoffset(c20.z); float fInvShadowmapSizeFar : packoffset(c20.w); float fShadowmapSizeDynamic : packoffset(c21); float fInvShadowmapSizeDynamic : packoffset(c21.y); float fShadowmapNormalScale : packoffset(c21.z); } cbuffer AOShadowConst : register(b4) { row_major float4x4 matAOShadowProjectionTexScale[16] : packoffset(c0); float4 vecSSAOShadowDirection[16] : packoffset(c64); float4 vecAOShadowDirection[16] : packoffset(c80); float fShadowmapSizeAO : packoffset(c96); float3 _emptyAO : packoffset(c96.y); } cbuffer shadowDynamicConst : register(b5) { row_major float4x4 matShadowProjectionTexScaleD[4] : packoffset(c0); float4 vecShadowViewPositionD[4] : packoffset(c16); } cbuffer frustum : register(b6) { float3 g_vFrustrumLB : packoffset(c0); float _emptyF0 : packoffset(c0.w); float3 g_vFrustrumRB : packoffset(c1); float _emptyF1 : packoffset(c1.w); float3 g_vFrustrumRT : packoffset(c2); float _emptyF2 : packoffset(c2.w); float3 g_vFrustrumLT : packoffset(c3); float _emptyF3 : packoffset(c3.w); float3 vecViewPosition : packoffset(c4); float _emptyF4 : packoffset(c4.w); } SamplerState samShadowMap0_s_s : register(s0); SamplerState samShadowMapD0_s_s : register(s1); SamplerState samShadowMapD1_s_s : register(s2); SamplerState samShadowMapD2_s_s : register(s3); SamplerState samShadowMapD3_s_s : register(s4); SamplerState samDepthNormal_s_s : register(s5); SamplerState samDepthNormalSkin_s_s : register(s6); SamplerState samNormal_s_s : register(s7); SamplerState samNormalLinear_s_s : register(s8); SamplerState samFarTerrain_s_s : register(s9); Texture2D<float4> texShadowMap0 : register(t0); Texture2D<float4> texShadowMapD0 : register(t1); Texture2D<float4> texShadowMapD1 : register(t2); Texture2D<float4> texShadowMapD2 : register(t3); Texture2D<float4> texShadowMapD3 : register(t4); Texture2D<float4> texDepthNormal : register(t5); Texture2D<float4> texDepthNormalSkin : register(t6); Texture2D<float4> texNormal : register(t7); Texture2D<float4> texFarTerrain : register(t8); // 3Dmigoto declarations #define cmp - Texture1D<float4> IniParams : register(t120); Texture2D<float4> StereoParams : register(t125); // Need DSS's matrix inversion tool to get an inverse view projection matrix #include <matrix.hlsl> void main( float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, float2 w1 : TEXCOORD2, float3 v2 : TEXCOORD1, out float4 o0 : SV_TARGET0) { float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13; uint4 bitmask, uiDest; float4 fDest; // Include standard 3DMigoto stereo variable float4 stereo = StereoParams.Load(0); // Copy matViewProjection into another matrix variable called 'vp' because it's easier to use matrix vp = matViewProjection; // Derive inverse viewprojection matrix from the viewprojection matrix needed for calculation below matrix ivp = inverse(vp); // Define 2 variable called tmp & tmp2 for later use float4 tmp; float4 tmp2; r0.x = texDepthNormal.Sample(samDepthNormal_s_s, v1.xy).x; r0.y = r0.x * -10 + 880000; r0.y = cmp(r0.y < 0); if (r0.y != 0) discard; r0.yz = float2(9.99999975e-006,10) * r0.xx; r0.w = dot(v2.xyz, v2.xyz); r0.w = rsqrt(r0.w); r1.xyz = v2.xyz * r0.www; r2.xyz = r1.xyz * r0.zzz; r3.xyz = r1.xyz * r0.zzz + vecViewPosition.xyz; r4.xyzw = texNormal.Sample(samNormal_s_s, v1.xy).xyzw; r0.z = 16 * r4.w; r0.z = floor(r0.z); r4.xyz = r4.xyz * float3(2,2,2) + float3(-1,-1,-1); r0.w = dot(r4.xyz, r4.xyz); r0.w = rsqrt(r0.w); r4.xyz = r4.xyz * r0.www; r4.xyz = r4.xyz + r4.xyz; r5.xy = -vecInvScreenSize.xy + v1.xy; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = vecInvScreenSize.xyx * float3(0,-1,1) + v1.xyx; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zy).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyzw = vecInvScreenSize.xyxy * float4(1,0,0,1) + v1.xyxy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xy = vecInvScreenSize.xy + v1.xy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zw).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = vecInvScreenSize.xyy * float3(-1,1,0) + v1.xyy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xz).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r0.w = dot(r4.xyz, r4.xyz); r0.w = rsqrt(r0.w); r4.xyz = r4.xyz * r0.www; r0.w = fInvShadowmapSizeNear * 1024; r0.w = max(1, r0.w); r5.xyz = r4.xyz * r0.www; r6.xyz = r5.xyz * float3(5,5,5) + r3.xyz; // Copy r6 into tmp to use tmp during calculations. Not really necessary, but possibly easier to understand tmp2.xyz = r6.xyz; // Need to have tmp.w = 1 during matrix calculation for it to be correct tmp2.w = 1; // Convert from a worldspace coordinate to a viewspace coordinate so we can use stereo correction by multiplying the worldspace coordinate by the viewprojection matrix tmp = mul(vp, tmp2); // Perform stereo correction tmp.x -= stereo.x * (tmp.w - stereo.y); // Convert the now stereo corrected value back to worldspace by multiplying it against the inverse viewprojection matrix, which will have a stereo corrected worldspace coordinate tmp2 = mul(ivp, tmp); // Copy contents of tmp into r6 so r6 is now stereo corrected r6.xyz = tmp2.xyz; r7.xyz = -vecShadowViewPosition0.xyz + r6.xyz; r8.xyzw = matShadowProjectionTexScale0._m10_m11_m12_m13 * r7.yyyy; r8.xyzw = r7.xxxx * matShadowProjectionTexScale0._m00_m01_m02_m03 + r8.xyzw; r7.xyzw = r7.zzzz * matShadowProjectionTexScale0._m20_m21_m22_m23 + r8.xyzw; r7.xyzw = matShadowProjectionTexScale0._m30_m31_m32_m33 + r7.xyzw; // removing rest of code due to size since no further changes required [/code] and here's how MY code would usually look (a bit more efficient). I provide some comments which explains the differences between the previous code and this code [code]// Shadows in game PS.. // ---- Created with 3Dmigoto v1.2.56 on Fri May 05 23:33:28 2017 cbuffer _Globals : register(b0) { float4x4 matFarCloudShadowProjectionTexScale : packoffset(c0); float4 vecInvScreenSize : packoffset(c4); float4x4 matViewProjection : packoffset(c5); float4x4 matViewProjectionTexScale : packoffset(c9); float4 vecCurrentPosition : packoffset(c13); float4 vecFarTerrainHeightConst : packoffset(c14); float3 vecFaceBonePosition : packoffset(c15); float fLongtermAOAdder : packoffset(c15.w); float fTerrainLongtermHeight : packoffset(c16) = {2000}; bool isLongTermAO : packoffset(c16.y); bool isSSAO : packoffset(c16.z); bool isSSAOReflect : packoffset(c16.w); bool isShadow : packoffset(c17); bool isSelfShadow : packoffset(c17.y); bool isRenderTerrainLongtermShadow : packoffset(c17.z); bool isGICalc : packoffset(c17.w); } cbuffer outdoorScatteringConst : register(b2) { float4 vecSunColorConst : packoffset(c0); float4 vecSunGlareColorConst : packoffset(c1); float4 vecHorizon0ColorConst : packoffset(c2); float4 vecHorizon1ColorConst : packoffset(c3); float4 vecSkyBaseColorConst : packoffset(c4); float4 vecExtinctionColorConst : packoffset(c5); float4 vecReighColorConst : packoffset(c6); float4 vecSunScatterColorConst : packoffset(c7); float4 vecAmbientColorConst[2] : packoffset(c8); float4 vecAmbientOcclusionColorConst : packoffset(c10); float4 vecDeepAOColorConst : packoffset(c11); float4 vecSkinAmbientColorConst : packoffset(c12); float4 vecHairAmbientColorConst : packoffset(c13); float4 vecEffectAmbientColorAlphaConst : packoffset(c14); float4 vecEffectAmbientColorConst : packoffset(c15); float4 vecEffectAmbientColorHit : packoffset(c16); float4 vecEffectAmbientColorHitAlpha : packoffset(c17); float3 vecSunDirection : packoffset(c18); float fSeaHeightConst : packoffset(c18.w); float3 vecMoonDirection : packoffset(c19); float IndoorRateRegion : packoffset(c19.w); float fSunScatterExpConst : packoffset(c20); float fSunGlareExpConst : packoffset(c20.y); float fSunExpConst : packoffset(c20.z); float fScatterDistanceFalloffConst : packoffset(c20.w); float fMieDistanceFalloffConst : packoffset(c21); float fMieHeightConst : packoffset(c21.y); float fReighDistanceFalloffConst : packoffset(c21.z); float fEnvIntensityConst : packoffset(c21.w); float fHorizonColorExp0Const : packoffset(c22); float fHorizonColorExp1Const : packoffset(c22.y); float fCharacterLightMultiply : packoffset(c22.z); float fCharacterLightMultiply2 : packoffset(c22.w); float RainAmount : packoffset(c23); float AirTemperature : packoffset(c23.y); float AirTemperatureForParticle : packoffset(c23.z); float IndoorRateRoof : packoffset(c23.w); float3 vecLightDirection : packoffset(c24); float fCloudLayer0Const : packoffset(c24.w); float fCloudLayer1Const : packoffset(c25); float fCloudLayer2Const : packoffset(c25.y); float fCloudLayer3Const : packoffset(c25.z); float fCloudLayer4Const : packoffset(c25.w); float fCloudLayer5Const : packoffset(c26); float fCloudLayer6Const : packoffset(c26.y); float fCloudLayer7Const : packoffset(c26.z); float fCloudLayer8Const : packoffset(c26.w); float fCloudLayer9Const : packoffset(c27); float fCloudLayer10Const : packoffset(c27.y); float fCloudLayer11Const : packoffset(c27.z); float fCloudLayer12Const : packoffset(c27.w); float4 fShaderTest : packoffset(c28) = {1,1,1,1}; float4 vecCloudColorConst : packoffset(c29); float3 vecColorMultiply : packoffset(c30); float fBrightnessMultiply : packoffset(c30.w); } cbuffer shadowConst : register(b3) { row_major float4x4 matShadowProjectionTexScale0 : packoffset(c0); row_major float4x4 matShadowProjectionTexScale1 : packoffset(c4); row_major float4x4 matShadowProjectionTexScale2 : packoffset(c8); row_major float4x4 matShadowProjectionTexScale3 : packoffset(c12); float4 vecShadowViewPosition0 : packoffset(c16); float4 vecShadowViewPosition1 : packoffset(c17); float4 vecShadowViewPosition2 : packoffset(c18); float4 vecShadowViewPosition3 : packoffset(c19); float fShadowmapSizeNear : packoffset(c20); float fShadowmapSizeFar : packoffset(c20.y); float fInvShadowmapSizeNear : packoffset(c20.z); float fInvShadowmapSizeFar : packoffset(c20.w); float fShadowmapSizeDynamic : packoffset(c21); float fInvShadowmapSizeDynamic : packoffset(c21.y); float fShadowmapNormalScale : packoffset(c21.z); } cbuffer AOShadowConst : register(b4) { row_major float4x4 matAOShadowProjectionTexScale[16] : packoffset(c0); float4 vecSSAOShadowDirection[16] : packoffset(c64); float4 vecAOShadowDirection[16] : packoffset(c80); float fShadowmapSizeAO : packoffset(c96); float3 _emptyAO : packoffset(c96.y); } cbuffer shadowDynamicConst : register(b5) { row_major float4x4 matShadowProjectionTexScaleD[4] : packoffset(c0); float4 vecShadowViewPositionD[4] : packoffset(c16); } cbuffer frustum : register(b6) { float3 g_vFrustrumLB : packoffset(c0); float _emptyF0 : packoffset(c0.w); float3 g_vFrustrumRB : packoffset(c1); float _emptyF1 : packoffset(c1.w); float3 g_vFrustrumRT : packoffset(c2); float _emptyF2 : packoffset(c2.w); float3 g_vFrustrumLT : packoffset(c3); float _emptyF3 : packoffset(c3.w); float3 vecViewPosition : packoffset(c4); float _emptyF4 : packoffset(c4.w); } SamplerState samShadowMap0_s_s : register(s0); SamplerState samShadowMapD0_s_s : register(s1); SamplerState samShadowMapD1_s_s : register(s2); SamplerState samShadowMapD2_s_s : register(s3); SamplerState samShadowMapD3_s_s : register(s4); SamplerState samDepthNormal_s_s : register(s5); SamplerState samDepthNormalSkin_s_s : register(s6); SamplerState samNormal_s_s : register(s7); SamplerState samNormalLinear_s_s : register(s8); SamplerState samFarTerrain_s_s : register(s9); Texture2D<float4> texShadowMap0 : register(t0); Texture2D<float4> texShadowMapD0 : register(t1); Texture2D<float4> texShadowMapD1 : register(t2); Texture2D<float4> texShadowMapD2 : register(t3); Texture2D<float4> texShadowMapD3 : register(t4); Texture2D<float4> texDepthNormal : register(t5); Texture2D<float4> texDepthNormalSkin : register(t6); Texture2D<float4> texNormal : register(t7); Texture2D<float4> texFarTerrain : register(t8); // 3Dmigoto declarations #define cmp - Texture1D<float4> IniParams : register(t120); Texture2D<float4> StereoParams : register(t125); #include <matrix.hlsl> void main( float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, float2 w1 : TEXCOORD2, float3 v2 : TEXCOORD1, out float4 o0 : SV_TARGET0) { float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13; uint4 bitmask, uiDest; float4 fDest; r0.x = texDepthNormal.Sample(samDepthNormal_s_s, v1.xy).x; r0.y = r0.x * -10 + 880000; r0.y = cmp(r0.y < 0); if (r0.y != 0) discard; r0.yz = float2(9.99999975e-006,10) * r0.xx; r0.w = dot(v2.xyz, v2.xyz); r0.w = rsqrt(r0.w); r1.xyz = v2.xyz * r0.www; r2.xyz = r1.xyz * r0.zzz; r3.xyz = r1.xyz * r0.zzz + vecViewPosition.xyz; r4.xyzw = texNormal.Sample(samNormal_s_s, v1.xy).xyzw; r0.z = 16 * r4.w; r0.z = floor(r0.z); r4.xyz = r4.xyz * float3(2,2,2) + float3(-1,-1,-1); r0.w = dot(r4.xyz, r4.xyz); r0.w = rsqrt(r0.w); r4.xyz = r4.xyz * r0.www; r4.xyz = r4.xyz + r4.xyz; r5.xy = -vecInvScreenSize.xy + v1.xy; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = vecInvScreenSize.xyx * float3(0,-1,1) + v1.xyx; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zy).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyzw = vecInvScreenSize.xyxy * float4(1,0,0,1) + v1.xyxy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xy = vecInvScreenSize.xy + v1.xy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zw).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = vecInvScreenSize.xyy * float3(-1,1,0) + v1.xyy; r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz; r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xz).xyz; r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz; r4.xyz = float3(-1,-1,-1) + r4.xyz; r0.w = dot(r4.xyz, r4.xyz); r0.w = rsqrt(r0.w); r4.xyz = r4.xyz * r0.www; r0.w = fInvShadowmapSizeNear * 1024; r0.w = max(1, r0.w); r5.xyz = r4.xyz * r0.www; r6.xyz = r5.xyz * float3(5,5,5) + r3.xyz; // Moved all the declarations down here because it really doesn't matter where you declare them, just as long as you declare them before you use them float4 stereo = StereoParams.Load(0); matrix vp = matViewProjection; matrix ivp = inverse(vp); // A lot of things grouped into this one line. While declaring a new variable, you can assign a value to it, so you don't need to waste a line of code only declaring a variable // Also note that tmp2 is not needed at all and is replaced in the multiply by 'float4(r6.xyz,1)'. If we knew r6.w equalled 1, then we would just use r6 by itself, but since we don't then 'float4(r6.xyz,1)' // lets use create an unnamed temporary 4-coordinate variable on the fly simply for the purpose of this one single use, which uses r6.xyz for the xyz coordinates and assigns the value of 1 to the w coordinate float4 tmp = mul(vp, float4(r6.xyz,1)); tmp.x -= stereo.x * (tmp.w - stereo.y); // This takes only the xyz coordinates from the multiply and copies them into the xyz coordinates of r6. r6.xyz = mul(ivp, tmp).xyz; r7.xyz = -vecShadowViewPosition0.xyz + r6.xyz; r8.xyzw = matShadowProjectionTexScale0._m10_m11_m12_m13 * r7.yyyy; r8.xyzw = r7.xxxx * matShadowProjectionTexScale0._m00_m01_m02_m03 + r8.xyzw; r7.xyzw = r7.zzzz * matShadowProjectionTexScale0._m20_m21_m22_m23 + r8.xyzw; r7.xyzw = matShadowProjectionTexScale0._m30_m31_m32_m33 + r7.xyzw; // rest removed [/code] There's a slight chance that rather than the fix occurring between lines 222 and 223 in your linked document and correcting r6 that the fix might actually need to occur between lines 223 and 224 and correcting r7, but I'm pretty sure that's not the case. I'll try to explain how I came to know how/where to fix this in a following post to come (may or may not be right away).
Since you requested I take a look here, I have. Looking at the code you linked to, it seems pretty standard enough that I'm pretty sure I can offer what the solution is. First off, you will need to include DSS's matrix.hlsl file in the ShaderFixes folder. You can find that file on his Github, or if you look you'll find it in most of my fixes.


Here's a "dumbed down" version that is a little easier to understand. I've included comments to try to help with understanding what's going on. Make particular note at the inclusions on lines 157-158, 170-183, & 238-256:

// Shadows in game PS..
// ---- Created with 3Dmigoto v1.2.56 on Fri May 05 23:33:28 2017

cbuffer _Globals : register(b0)
{
float4x4 matFarCloudShadowProjectionTexScale : packoffset(c0);
float4 vecInvScreenSize : packoffset(c4);
float4x4 matViewProjection : packoffset(c5);
float4x4 matViewProjectionTexScale : packoffset(c9);
float4 vecCurrentPosition : packoffset(c13);
float4 vecFarTerrainHeightConst : packoffset(c14);
float3 vecFaceBonePosition : packoffset(c15);
float fLongtermAOAdder : packoffset(c15.w);
float fTerrainLongtermHeight : packoffset(c16) = {2000};
bool isLongTermAO : packoffset(c16.y);
bool isSSAO : packoffset(c16.z);
bool isSSAOReflect : packoffset(c16.w);
bool isShadow : packoffset(c17);
bool isSelfShadow : packoffset(c17.y);
bool isRenderTerrainLongtermShadow : packoffset(c17.z);
bool isGICalc : packoffset(c17.w);
}

cbuffer outdoorScatteringConst : register(b2)
{
float4 vecSunColorConst : packoffset(c0);
float4 vecSunGlareColorConst : packoffset(c1);
float4 vecHorizon0ColorConst : packoffset(c2);
float4 vecHorizon1ColorConst : packoffset(c3);
float4 vecSkyBaseColorConst : packoffset(c4);
float4 vecExtinctionColorConst : packoffset(c5);
float4 vecReighColorConst : packoffset(c6);
float4 vecSunScatterColorConst : packoffset(c7);
float4 vecAmbientColorConst[2] : packoffset(c8);
float4 vecAmbientOcclusionColorConst : packoffset(c10);
float4 vecDeepAOColorConst : packoffset(c11);
float4 vecSkinAmbientColorConst : packoffset(c12);
float4 vecHairAmbientColorConst : packoffset(c13);
float4 vecEffectAmbientColorAlphaConst : packoffset(c14);
float4 vecEffectAmbientColorConst : packoffset(c15);
float4 vecEffectAmbientColorHit : packoffset(c16);
float4 vecEffectAmbientColorHitAlpha : packoffset(c17);
float3 vecSunDirection : packoffset(c18);
float fSeaHeightConst : packoffset(c18.w);
float3 vecMoonDirection : packoffset(c19);
float IndoorRateRegion : packoffset(c19.w);
float fSunScatterExpConst : packoffset(c20);
float fSunGlareExpConst : packoffset(c20.y);
float fSunExpConst : packoffset(c20.z);
float fScatterDistanceFalloffConst : packoffset(c20.w);
float fMieDistanceFalloffConst : packoffset(c21);
float fMieHeightConst : packoffset(c21.y);
float fReighDistanceFalloffConst : packoffset(c21.z);
float fEnvIntensityConst : packoffset(c21.w);
float fHorizonColorExp0Const : packoffset(c22);
float fHorizonColorExp1Const : packoffset(c22.y);
float fCharacterLightMultiply : packoffset(c22.z);
float fCharacterLightMultiply2 : packoffset(c22.w);
float RainAmount : packoffset(c23);
float AirTemperature : packoffset(c23.y);
float AirTemperatureForParticle : packoffset(c23.z);
float IndoorRateRoof : packoffset(c23.w);
float3 vecLightDirection : packoffset(c24);
float fCloudLayer0Const : packoffset(c24.w);
float fCloudLayer1Const : packoffset(c25);
float fCloudLayer2Const : packoffset(c25.y);
float fCloudLayer3Const : packoffset(c25.z);
float fCloudLayer4Const : packoffset(c25.w);
float fCloudLayer5Const : packoffset(c26);
float fCloudLayer6Const : packoffset(c26.y);
float fCloudLayer7Const : packoffset(c26.z);
float fCloudLayer8Const : packoffset(c26.w);
float fCloudLayer9Const : packoffset(c27);
float fCloudLayer10Const : packoffset(c27.y);
float fCloudLayer11Const : packoffset(c27.z);
float fCloudLayer12Const : packoffset(c27.w);
float4 fShaderTest : packoffset(c28) = {1,1,1,1};
float4 vecCloudColorConst : packoffset(c29);
float3 vecColorMultiply : packoffset(c30);
float fBrightnessMultiply : packoffset(c30.w);
}

cbuffer shadowConst : register(b3)
{
row_major float4x4 matShadowProjectionTexScale0 : packoffset(c0);
row_major float4x4 matShadowProjectionTexScale1 : packoffset(c4);
row_major float4x4 matShadowProjectionTexScale2 : packoffset(c8);
row_major float4x4 matShadowProjectionTexScale3 : packoffset(c12);
float4 vecShadowViewPosition0 : packoffset(c16);
float4 vecShadowViewPosition1 : packoffset(c17);
float4 vecShadowViewPosition2 : packoffset(c18);
float4 vecShadowViewPosition3 : packoffset(c19);
float fShadowmapSizeNear : packoffset(c20);
float fShadowmapSizeFar : packoffset(c20.y);
float fInvShadowmapSizeNear : packoffset(c20.z);
float fInvShadowmapSizeFar : packoffset(c20.w);
float fShadowmapSizeDynamic : packoffset(c21);
float fInvShadowmapSizeDynamic : packoffset(c21.y);
float fShadowmapNormalScale : packoffset(c21.z);
}

cbuffer AOShadowConst : register(b4)
{
row_major float4x4 matAOShadowProjectionTexScale[16] : packoffset(c0);
float4 vecSSAOShadowDirection[16] : packoffset(c64);
float4 vecAOShadowDirection[16] : packoffset(c80);
float fShadowmapSizeAO : packoffset(c96);
float3 _emptyAO : packoffset(c96.y);
}

cbuffer shadowDynamicConst : register(b5)
{
row_major float4x4 matShadowProjectionTexScaleD[4] : packoffset(c0);
float4 vecShadowViewPositionD[4] : packoffset(c16);
}

cbuffer frustum : register(b6)
{
float3 g_vFrustrumLB : packoffset(c0);
float _emptyF0 : packoffset(c0.w);
float3 g_vFrustrumRB : packoffset(c1);
float _emptyF1 : packoffset(c1.w);
float3 g_vFrustrumRT : packoffset(c2);
float _emptyF2 : packoffset(c2.w);
float3 g_vFrustrumLT : packoffset(c3);
float _emptyF3 : packoffset(c3.w);
float3 vecViewPosition : packoffset(c4);
float _emptyF4 : packoffset(c4.w);
}

SamplerState samShadowMap0_s_s : register(s0);
SamplerState samShadowMapD0_s_s : register(s1);
SamplerState samShadowMapD1_s_s : register(s2);
SamplerState samShadowMapD2_s_s : register(s3);
SamplerState samShadowMapD3_s_s : register(s4);
SamplerState samDepthNormal_s_s : register(s5);
SamplerState samDepthNormalSkin_s_s : register(s6);
SamplerState samNormal_s_s : register(s7);
SamplerState samNormalLinear_s_s : register(s8);
SamplerState samFarTerrain_s_s : register(s9);
Texture2D<float4> texShadowMap0 : register(t0);
Texture2D<float4> texShadowMapD0 : register(t1);
Texture2D<float4> texShadowMapD1 : register(t2);
Texture2D<float4> texShadowMapD2 : register(t3);
Texture2D<float4> texShadowMapD3 : register(t4);
Texture2D<float4> texDepthNormal : register(t5);
Texture2D<float4> texDepthNormalSkin : register(t6);
Texture2D<float4> texNormal : register(t7);
Texture2D<float4> texFarTerrain : register(t8);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);

// Need DSS's matrix inversion tool to get an inverse view projection matrix
#include <matrix.hlsl>

void main(
float4 v0 : SV_POSITION0,
float2 v1 : TEXCOORD0,
float2 w1 : TEXCOORD2,
float3 v2 : TEXCOORD1,
out float4 o0 : SV_TARGET0)
{
float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13;
uint4 bitmask, uiDest;
float4 fDest;

// Include standard 3DMigoto stereo variable
float4 stereo = StereoParams.Load(0);

// Copy matViewProjection into another matrix variable called 'vp' because it's easier to use
matrix vp = matViewProjection;

// Derive inverse viewprojection matrix from the viewprojection matrix needed for calculation below
matrix ivp = inverse(vp);

// Define 2 variable called tmp & tmp2 for later use
float4 tmp;
float4 tmp2;

r0.x = texDepthNormal.Sample(samDepthNormal_s_s, v1.xy).x;
r0.y = r0.x * -10 + 880000;
r0.y = cmp(r0.y < 0);
if (r0.y != 0) discard;
r0.yz = float2(9.99999975e-006,10) * r0.xx;
r0.w = dot(v2.xyz, v2.xyz);
r0.w = rsqrt(r0.w);
r1.xyz = v2.xyz * r0.www;
r2.xyz = r1.xyz * r0.zzz;
r3.xyz = r1.xyz * r0.zzz + vecViewPosition.xyz;
r4.xyzw = texNormal.Sample(samNormal_s_s, v1.xy).xyzw;
r0.z = 16 * r4.w;
r0.z = floor(r0.z);
r4.xyz = r4.xyz * float3(2,2,2) + float3(-1,-1,-1);
r0.w = dot(r4.xyz, r4.xyz);
r0.w = rsqrt(r0.w);
r4.xyz = r4.xyz * r0.www;
r4.xyz = r4.xyz + r4.xyz;
r5.xy = -vecInvScreenSize.xy + v1.xy;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = vecInvScreenSize.xyx * float3(0,-1,1) + v1.xyx;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zy).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyzw = vecInvScreenSize.xyxy * float4(1,0,0,1) + v1.xyxy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xy = vecInvScreenSize.xy + v1.xy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zw).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = vecInvScreenSize.xyy * float3(-1,1,0) + v1.xyy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xz).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r0.w = dot(r4.xyz, r4.xyz);
r0.w = rsqrt(r0.w);
r4.xyz = r4.xyz * r0.www;
r0.w = fInvShadowmapSizeNear * 1024;
r0.w = max(1, r0.w);
r5.xyz = r4.xyz * r0.www;
r6.xyz = r5.xyz * float3(5,5,5) + r3.xyz;

// Copy r6 into tmp to use tmp during calculations. Not really necessary, but possibly easier to understand
tmp2.xyz = r6.xyz;

// Need to have tmp.w = 1 during matrix calculation for it to be correct
tmp2.w = 1;

// Convert from a worldspace coordinate to a viewspace coordinate so we can use stereo correction by multiplying the worldspace coordinate by the viewprojection matrix
tmp = mul(vp, tmp2);

// Perform stereo correction
tmp.x -= stereo.x * (tmp.w - stereo.y);

// Convert the now stereo corrected value back to worldspace by multiplying it against the inverse viewprojection matrix, which will have a stereo corrected worldspace coordinate
tmp2 = mul(ivp, tmp);

// Copy contents of tmp into r6 so r6 is now stereo corrected
r6.xyz = tmp2.xyz;


r7.xyz = -vecShadowViewPosition0.xyz + r6.xyz;
r8.xyzw = matShadowProjectionTexScale0._m10_m11_m12_m13 * r7.yyyy;
r8.xyzw = r7.xxxx * matShadowProjectionTexScale0._m00_m01_m02_m03 + r8.xyzw;
r7.xyzw = r7.zzzz * matShadowProjectionTexScale0._m20_m21_m22_m23 + r8.xyzw;
r7.xyzw = matShadowProjectionTexScale0._m30_m31_m32_m33 + r7.xyzw;

// removing rest of code due to size since no further changes required


and here's how MY code would usually look (a bit more efficient). I provide some comments which explains the differences between the previous code and this code

// Shadows in game PS..
// ---- Created with 3Dmigoto v1.2.56 on Fri May 05 23:33:28 2017

cbuffer _Globals : register(b0)
{
float4x4 matFarCloudShadowProjectionTexScale : packoffset(c0);
float4 vecInvScreenSize : packoffset(c4);
float4x4 matViewProjection : packoffset(c5);
float4x4 matViewProjectionTexScale : packoffset(c9);
float4 vecCurrentPosition : packoffset(c13);
float4 vecFarTerrainHeightConst : packoffset(c14);
float3 vecFaceBonePosition : packoffset(c15);
float fLongtermAOAdder : packoffset(c15.w);
float fTerrainLongtermHeight : packoffset(c16) = {2000};
bool isLongTermAO : packoffset(c16.y);
bool isSSAO : packoffset(c16.z);
bool isSSAOReflect : packoffset(c16.w);
bool isShadow : packoffset(c17);
bool isSelfShadow : packoffset(c17.y);
bool isRenderTerrainLongtermShadow : packoffset(c17.z);
bool isGICalc : packoffset(c17.w);
}

cbuffer outdoorScatteringConst : register(b2)
{
float4 vecSunColorConst : packoffset(c0);
float4 vecSunGlareColorConst : packoffset(c1);
float4 vecHorizon0ColorConst : packoffset(c2);
float4 vecHorizon1ColorConst : packoffset(c3);
float4 vecSkyBaseColorConst : packoffset(c4);
float4 vecExtinctionColorConst : packoffset(c5);
float4 vecReighColorConst : packoffset(c6);
float4 vecSunScatterColorConst : packoffset(c7);
float4 vecAmbientColorConst[2] : packoffset(c8);
float4 vecAmbientOcclusionColorConst : packoffset(c10);
float4 vecDeepAOColorConst : packoffset(c11);
float4 vecSkinAmbientColorConst : packoffset(c12);
float4 vecHairAmbientColorConst : packoffset(c13);
float4 vecEffectAmbientColorAlphaConst : packoffset(c14);
float4 vecEffectAmbientColorConst : packoffset(c15);
float4 vecEffectAmbientColorHit : packoffset(c16);
float4 vecEffectAmbientColorHitAlpha : packoffset(c17);
float3 vecSunDirection : packoffset(c18);
float fSeaHeightConst : packoffset(c18.w);
float3 vecMoonDirection : packoffset(c19);
float IndoorRateRegion : packoffset(c19.w);
float fSunScatterExpConst : packoffset(c20);
float fSunGlareExpConst : packoffset(c20.y);
float fSunExpConst : packoffset(c20.z);
float fScatterDistanceFalloffConst : packoffset(c20.w);
float fMieDistanceFalloffConst : packoffset(c21);
float fMieHeightConst : packoffset(c21.y);
float fReighDistanceFalloffConst : packoffset(c21.z);
float fEnvIntensityConst : packoffset(c21.w);
float fHorizonColorExp0Const : packoffset(c22);
float fHorizonColorExp1Const : packoffset(c22.y);
float fCharacterLightMultiply : packoffset(c22.z);
float fCharacterLightMultiply2 : packoffset(c22.w);
float RainAmount : packoffset(c23);
float AirTemperature : packoffset(c23.y);
float AirTemperatureForParticle : packoffset(c23.z);
float IndoorRateRoof : packoffset(c23.w);
float3 vecLightDirection : packoffset(c24);
float fCloudLayer0Const : packoffset(c24.w);
float fCloudLayer1Const : packoffset(c25);
float fCloudLayer2Const : packoffset(c25.y);
float fCloudLayer3Const : packoffset(c25.z);
float fCloudLayer4Const : packoffset(c25.w);
float fCloudLayer5Const : packoffset(c26);
float fCloudLayer6Const : packoffset(c26.y);
float fCloudLayer7Const : packoffset(c26.z);
float fCloudLayer8Const : packoffset(c26.w);
float fCloudLayer9Const : packoffset(c27);
float fCloudLayer10Const : packoffset(c27.y);
float fCloudLayer11Const : packoffset(c27.z);
float fCloudLayer12Const : packoffset(c27.w);
float4 fShaderTest : packoffset(c28) = {1,1,1,1};
float4 vecCloudColorConst : packoffset(c29);
float3 vecColorMultiply : packoffset(c30);
float fBrightnessMultiply : packoffset(c30.w);
}

cbuffer shadowConst : register(b3)
{
row_major float4x4 matShadowProjectionTexScale0 : packoffset(c0);
row_major float4x4 matShadowProjectionTexScale1 : packoffset(c4);
row_major float4x4 matShadowProjectionTexScale2 : packoffset(c8);
row_major float4x4 matShadowProjectionTexScale3 : packoffset(c12);
float4 vecShadowViewPosition0 : packoffset(c16);
float4 vecShadowViewPosition1 : packoffset(c17);
float4 vecShadowViewPosition2 : packoffset(c18);
float4 vecShadowViewPosition3 : packoffset(c19);
float fShadowmapSizeNear : packoffset(c20);
float fShadowmapSizeFar : packoffset(c20.y);
float fInvShadowmapSizeNear : packoffset(c20.z);
float fInvShadowmapSizeFar : packoffset(c20.w);
float fShadowmapSizeDynamic : packoffset(c21);
float fInvShadowmapSizeDynamic : packoffset(c21.y);
float fShadowmapNormalScale : packoffset(c21.z);
}

cbuffer AOShadowConst : register(b4)
{
row_major float4x4 matAOShadowProjectionTexScale[16] : packoffset(c0);
float4 vecSSAOShadowDirection[16] : packoffset(c64);
float4 vecAOShadowDirection[16] : packoffset(c80);
float fShadowmapSizeAO : packoffset(c96);
float3 _emptyAO : packoffset(c96.y);
}

cbuffer shadowDynamicConst : register(b5)
{
row_major float4x4 matShadowProjectionTexScaleD[4] : packoffset(c0);
float4 vecShadowViewPositionD[4] : packoffset(c16);
}

cbuffer frustum : register(b6)
{
float3 g_vFrustrumLB : packoffset(c0);
float _emptyF0 : packoffset(c0.w);
float3 g_vFrustrumRB : packoffset(c1);
float _emptyF1 : packoffset(c1.w);
float3 g_vFrustrumRT : packoffset(c2);
float _emptyF2 : packoffset(c2.w);
float3 g_vFrustrumLT : packoffset(c3);
float _emptyF3 : packoffset(c3.w);
float3 vecViewPosition : packoffset(c4);
float _emptyF4 : packoffset(c4.w);
}

SamplerState samShadowMap0_s_s : register(s0);
SamplerState samShadowMapD0_s_s : register(s1);
SamplerState samShadowMapD1_s_s : register(s2);
SamplerState samShadowMapD2_s_s : register(s3);
SamplerState samShadowMapD3_s_s : register(s4);
SamplerState samDepthNormal_s_s : register(s5);
SamplerState samDepthNormalSkin_s_s : register(s6);
SamplerState samNormal_s_s : register(s7);
SamplerState samNormalLinear_s_s : register(s8);
SamplerState samFarTerrain_s_s : register(s9);
Texture2D<float4> texShadowMap0 : register(t0);
Texture2D<float4> texShadowMapD0 : register(t1);
Texture2D<float4> texShadowMapD1 : register(t2);
Texture2D<float4> texShadowMapD2 : register(t3);
Texture2D<float4> texShadowMapD3 : register(t4);
Texture2D<float4> texDepthNormal : register(t5);
Texture2D<float4> texDepthNormalSkin : register(t6);
Texture2D<float4> texNormal : register(t7);
Texture2D<float4> texFarTerrain : register(t8);


// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);
#include <matrix.hlsl>

void main(
float4 v0 : SV_POSITION0,
float2 v1 : TEXCOORD0,
float2 w1 : TEXCOORD2,
float3 v2 : TEXCOORD1,
out float4 o0 : SV_TARGET0)
{
float4 r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13;
uint4 bitmask, uiDest;
float4 fDest;


r0.x = texDepthNormal.Sample(samDepthNormal_s_s, v1.xy).x;
r0.y = r0.x * -10 + 880000;
r0.y = cmp(r0.y < 0);
if (r0.y != 0) discard;
r0.yz = float2(9.99999975e-006,10) * r0.xx;
r0.w = dot(v2.xyz, v2.xyz);
r0.w = rsqrt(r0.w);
r1.xyz = v2.xyz * r0.www;
r2.xyz = r1.xyz * r0.zzz;
r3.xyz = r1.xyz * r0.zzz + vecViewPosition.xyz;
r4.xyzw = texNormal.Sample(samNormal_s_s, v1.xy).xyzw;
r0.z = 16 * r4.w;
r0.z = floor(r0.z);
r4.xyz = r4.xyz * float3(2,2,2) + float3(-1,-1,-1);
r0.w = dot(r4.xyz, r4.xyz);
r0.w = rsqrt(r0.w);
r4.xyz = r4.xyz * r0.www;
r4.xyz = r4.xyz + r4.xyz;
r5.xy = -vecInvScreenSize.xy + v1.xy;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = vecInvScreenSize.xyx * float3(0,-1,1) + v1.xyx;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zy).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyzw = vecInvScreenSize.xyxy * float4(1,0,0,1) + v1.xyxy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xy = vecInvScreenSize.xy + v1.xy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.zw).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = vecInvScreenSize.xyy * float3(-1,1,0) + v1.xyy;
r6.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xy).xyz;
r4.xyz = r6.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r5.xyz = texNormal.Sample(samNormalLinear_s_s, r5.xz).xyz;
r4.xyz = r5.xyz * float3(2,2,2) + r4.xyz;
r4.xyz = float3(-1,-1,-1) + r4.xyz;
r0.w = dot(r4.xyz, r4.xyz);
r0.w = rsqrt(r0.w);
r4.xyz = r4.xyz * r0.www;
r0.w = fInvShadowmapSizeNear * 1024;
r0.w = max(1, r0.w);
r5.xyz = r4.xyz * r0.www;
r6.xyz = r5.xyz * float3(5,5,5) + r3.xyz;

// Moved all the declarations down here because it really doesn't matter where you declare them, just as long as you declare them before you use them
float4 stereo = StereoParams.Load(0);
matrix vp = matViewProjection;
matrix ivp = inverse(vp);

// A lot of things grouped into this one line. While declaring a new variable, you can assign a value to it, so you don't need to waste a line of code only declaring a variable
// Also note that tmp2 is not needed at all and is replaced in the multiply by 'float4(r6.xyz,1)'. If we knew r6.w equalled 1, then we would just use r6 by itself, but since we don't then 'float4(r6.xyz,1)'
// lets use create an unnamed temporary 4-coordinate variable on the fly simply for the purpose of this one single use, which uses r6.xyz for the xyz coordinates and assigns the value of 1 to the w coordinate
float4 tmp = mul(vp, float4(r6.xyz,1));

tmp.x -= stereo.x * (tmp.w - stereo.y);

// This takes only the xyz coordinates from the multiply and copies them into the xyz coordinates of r6.
r6.xyz = mul(ivp, tmp).xyz;

r7.xyz = -vecShadowViewPosition0.xyz + r6.xyz;
r8.xyzw = matShadowProjectionTexScale0._m10_m11_m12_m13 * r7.yyyy;
r8.xyzw = r7.xxxx * matShadowProjectionTexScale0._m00_m01_m02_m03 + r8.xyzw;
r7.xyzw = r7.zzzz * matShadowProjectionTexScale0._m20_m21_m22_m23 + r8.xyzw;
r7.xyzw = matShadowProjectionTexScale0._m30_m31_m32_m33 + r7.xyzw;

// rest removed


There's a slight chance that rather than the fix occurring between lines 222 and 223 in your linked document and correcting r6 that the fix might actually need to occur between lines 223 and 224 and correcting r7, but I'm pretty sure that's not the case.

I'll try to explain how I came to know how/where to fix this in a following post to come (may or may not be right away).

3D Gaming Rig: CPU: i7 7700K @ 4.9Ghz | Mobo: Asus Maximus Hero VIII | RAM: Corsair Dominator 16GB | GPU: 2 x GTX 1080 Ti SLI | 3xSSDs for OS and Apps, 2 x HDD's for 11GB storage | PSU: Seasonic X-1250 M2| Case: Corsair C70 | Cooling: Corsair H115i Hydro cooler | Displays: Asus PG278QR, BenQ XL2420TX & BenQ HT1075 | OS: Windows 10 Pro + Windows 7 dual boot

Like my fixes? Dontations can be made to: www.paypal.me/DShanz or rshannonca@gmail.com
Like electronic music? Check out: www.soundcloud.com/dj-ryan-king

Posted 05/06/2017 02:57 PM   
WOW Man that is freaking amazing.. I would love to understand at this level.. Alot of what you said made sence and I was always wondering what thoe HLSL files where in some fixes I seen.. I really appreciate helping here I just hope I can gain an understadning of this to be able to fix them myself.. I look forward to your explanation but take your time I know you are busy with things ;) So basically If I inject that into the PS it should work or is there more code to be added??
WOW Man that is freaking amazing.. I would love to understand at this level.. Alot of what you said made sence and I was always wondering what thoe HLSL files where in some fixes I seen..

I really appreciate helping here I just hope I can gain an understadning of this to be able to fix them myself..

I look forward to your explanation but take your time I know you are busy with things ;)

So basically If I inject that into the PS it should work or is there more code to be added??

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/06/2017 10:33 PM   
As long as you have the matrix.hlsl file, then there's a good chance that if you use that code in the PS that it will fix the shadows. Sometimes you may also need to do an adjustment in the VS as well, but more often than not you don't.
As long as you have the matrix.hlsl file, then there's a good chance that if you use that code in the PS that it will fix the shadows. Sometimes you may also need to do an adjustment in the VS as well, but more often than not you don't.

3D Gaming Rig: CPU: i7 7700K @ 4.9Ghz | Mobo: Asus Maximus Hero VIII | RAM: Corsair Dominator 16GB | GPU: 2 x GTX 1080 Ti SLI | 3xSSDs for OS and Apps, 2 x HDD's for 11GB storage | PSU: Seasonic X-1250 M2| Case: Corsair C70 | Cooling: Corsair H115i Hydro cooler | Displays: Asus PG278QR, BenQ XL2420TX & BenQ HT1075 | OS: Windows 10 Pro + Windows 7 dual boot

Like my fixes? Dontations can be made to: www.paypal.me/DShanz or rshannonca@gmail.com
Like electronic music? Check out: www.soundcloud.com/dj-ryan-king

Posted 05/06/2017 11:11 PM   
Well I made the correction in the shader I linked at pastebin I do not think it worked.. Are the shadows supposed to have a double image when not looking through the glasses?? They seemed to still be in 2D?? I removed the rest of the fix and just put in the PS I posted with the included fix you made and installed the Matrix.hlsl file in the shader fix folder..
Well I made the correction in the shader I linked at pastebin I do not think it worked.. Are the shadows supposed to have a double image when not looking through the glasses??

They seemed to still be in 2D?? I removed the rest of the fix and just put in the PS I posted with the included fix you made and installed the Matrix.hlsl file in the shader fix folder..

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/06/2017 11:18 PM   
I will see IF I need to make a correction in the VS too as well.. Also what you where saying about correcting r7 could that be an issue here??
I will see IF I need to make a correction in the VS too as well.. Also what you where saying about correcting r7 could that be an issue here??

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/06/2017 11:32 PM   
[quote="The_Nephilim"]Well if you can get a screenshot of what you see that is wrong I would appreciate it.. I did tonight see some issues withe the cliffs near the shoreline it had sort of a one eye effect.. Really wierd and I did find a shader for it but it seemed to have broken some other things so that was definetley problay part of the problem you are seeing..[/quote] Game looks great! I really cant complain right now but since you ask. Would it be troublesome to fix the reflection on the sea? Would that be the same issue with the puddles. I will attach screenshot if it lets me. Edit: Had to upload it on imgur: [url]http://imgur.com/a/PAVW9[/url]
The_Nephilim said:Well if you can get a screenshot of what you see that is wrong I would appreciate it..

I did tonight see some issues withe the cliffs near the shoreline it had sort of a one eye effect..

Really wierd and I did find a shader for it but it seemed to have broken some other things so that was definetley problay part of the problem you are seeing..


Game looks great! I really cant complain right now but since you ask. Would it be troublesome to fix the reflection on the sea? Would that be the same issue with the puddles. I will attach screenshot if it lets me.


Edit: Had to upload it on imgur:

http://imgur.com/a/PAVW9

Posted 05/07/2017 06:06 AM   
In my case, nothing changed after installing this fix, except that hud was able to move back and forth after pressing -. The shadow is still rendered as 2d, and some textures on the road are also rendered as 2d. Of course, s3d Is the case
In my case, nothing changed after installing this fix, except that hud was able to move back and forth after pressing -. The shadow is still rendered as 2d, and some textures on the road are also rendered as 2d. Of course, s3d Is the case

i7 8700K @4.9
GTX1080Ti
Asrock Z370 Gamming K6
Windows10 64bit
LG OLED UHD 3dtv 55E6K

Posted 05/08/2017 04:43 AM   
Well there should be no more shadows and the road should be in 3D as should everything else.. Please check the settings in the screenshot I linked below.. and did you follow the instructions as written at HelixMod Site??
Well there should be no more shadows and the road should be in 3D as should everything else.. Please check the settings in the screenshot I linked below.. and did you follow the instructions as written at HelixMod Site??

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/08/2017 05:32 AM   
[quote="The_Nephilim"]Well there should be no more shadows and the road should be in 3D as should everything else.. Please check the settings in the screenshot I linked below.. and did you follow the instructions as written at HelixMod Site?? [/quote] First, I appreciate your comment. I do not know exactly what process to follow because I am not accustomed to English. All I did was download the fix.zip file and extracted it and copy it to the black desert folder, It is all that I have guessed that I wrote it down. I also want you to let me know exactly what course I must do. I did the same setting but it was pointless.
The_Nephilim said:Well there should be no more shadows and the road should be in 3D as should everything else.. Please check the settings in the screenshot I linked below.. and did you follow the instructions as written at HelixMod Site??



First, I appreciate your comment. I do not know exactly what process to follow because I am not accustomed to English. All I did was download the fix.zip file and extracted it and copy it to the black desert folder, It is all that I have guessed that I wrote it down. I also want you to let me know exactly what course I must do. I did the same setting but it was pointless.

i7 8700K @4.9
GTX1080Ti
Asrock Z370 Gamming K6
Windows10 64bit
LG OLED UHD 3dtv 55E6K

Posted 05/08/2017 07:19 AM   
ok you have to put it in where the EXE file is located for the game..
ok you have to put it in where the EXE file is located for the game..

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/08/2017 07:32 AM   
C:\Program Files (x86)\Black Desert Online\bin64 here is where the exe is lovcated on my PC
C:\Program Files (x86)\Black Desert Online\bin64


here is where the exe is lovcated on my PC

Intel i5 7600K @ 4.8ghz / MSI Z270 SLI / Asus 1080GTX - 416.16 / Optoma HD142x Projector / 1 4'x10' Curved Screen PVC / TrackIR / HOTAS Cougar / Cougar MFD's / Track IR / NVidia 3D Vision / Win 10 64bit

Posted 05/08/2017 07:32 AM   
[quote="The_Nephilim"]C:\Program Files (x86)\Black Desert Online\bin64 here is where the exe is lovcated on my PC[/quote] I copied it to black desert root folder,and tested it and copied it to black desert\bin64 folder, and tested it. But result was same By the way Can I just copy it to a folder? Or I wonder if there is something else I need to do
The_Nephilim said:C:\Program Files (x86)\Black Desert Online\bin64


here is where the exe is lovcated on my PC


I copied it to black desert root folder,and tested it and copied it to black desert\bin64 folder, and tested it.
But result was same

By the way Can I just copy it to a folder? Or I wonder if there is something else I need to do

i7 8700K @4.9
GTX1080Ti
Asrock Z370 Gamming K6
Windows10 64bit
LG OLED UHD 3dtv 55E6K

Posted 05/08/2017 07:49 AM   
It goes in the bin64 directory, so if it's still borked there is something wrong. However, he has done a really good job of this but it's not perfect, so make sure you very closely follow the graphics effects recommended settings on the site and make sure you do NOT have high end mode on, also make sure you follow instructions regarding convergence settings because otherwise the ground will look very bad.
It goes in the bin64 directory, so if it's still borked there is something wrong.

However, he has done a really good job of this but it's not perfect, so make sure you very closely follow the graphics effects recommended settings on the site and make sure you do NOT have high end mode on, also make sure you follow instructions regarding convergence settings because otherwise the ground will look very bad.

i7-4790K CPU 4.8Ghz stable overclock.
16 GB RAM Corsair
EVGA 1080TI SLI
Samsung SSD 840Pro
ASUS Z97-WS
3D Surround ASUS Rog Swift PG278Q(R), 2x PG278Q (yes it works)
Obutto R3volution.
Windows 10 pro 64x (Windows 7 Dual boot)

Posted 05/08/2017 08:20 AM   
  10 / 11    
Scroll To Top