3Dmigoto now open-source...
  39 / 141    
Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor. We could also use hard-links, but all of this is pretty small wins compared to other stuff we can spend time upon. If there is a decent offline/non-tool workaround I still think we are better served to use those. I'm sure you've all heard of "technical-debt". I'm working as a consultant, and I typically come into organizations that are actually frozen in place because of their technical-debt. Technical-debt generally is the same thing as complexity. It's easy to put in one more 'if' statement, and hack workaround, and small tweak, and tiny feature request, and emergency change, until after awhile you have the classic spaghetti code that no one can add anything to, or fix bugs in without breaking something else. That's technical-debt, and it's why I'm such a pain-in-the-ass about discouraging complexity. By the far the biggest challenge I see in my consulting jobs is that creeping complexity.
Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor.

We could also use hard-links, but all of this is pretty small wins compared to other stuff we can spend time upon. If there is a decent offline/non-tool workaround I still think we are better served to use those.


I'm sure you've all heard of "technical-debt". I'm working as a consultant, and I typically come into organizations that are actually frozen in place because of their technical-debt. Technical-debt generally is the same thing as complexity. It's easy to put in one more 'if' statement, and hack workaround, and small tweak, and tiny feature request, and emergency change, until after awhile you have the classic spaghetti code that no one can add anything to, or fix bugs in without breaking something else. That's technical-debt, and it's why I'm such a pain-in-the-ass about discouraging complexity.

By the far the biggest challenge I see in my consulting jobs is that creeping complexity.

Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers

Posted 12/02/2015 06:37 AM   
I totally understand your concerns about the overhead the folder crawling may cause, but that folder structure is only needed during the modding process. My game is on the SSD so I do not feel any delay when pressing F10. This folder/renamed shaders implementation could be used only with hunting flag set to > 0 for example and work in optimized way for the end user. You are the masters here, so it's your call, I'm not trying to enforce any of my ideas, just trying to help to make the modding process less time consuming. I'm gonna try the shortcuts/symlinks method today. Thank you for fixing the missing variable modifiers.
I totally understand your concerns about the overhead the folder crawling may cause, but that folder structure is only needed during the modding process. My game is on the SSD so I do not feel any delay when pressing F10. This folder/renamed shaders implementation could be used only with hunting flag set to > 0 for example and work in optimized way for the end user. You are the masters here, so it's your call, I'm not trying to enforce any of my ideas, just trying to help to make the modding process less time consuming.

I'm gonna try the shortcuts/symlinks method today.
Thank you for fixing the missing variable modifiers.

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/02/2015 02:19 PM   
[quote="bo3b"]Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor. We could also use hard-links, but all of this is pretty small wins compared to other stuff we can spend time upon. If there is a decent offline/non-tool workaround I still think we are better served to use those. I'm sure you've all heard of "technical-debt". I'm working as a consultant, and I typically come into organizations that are actually frozen in place because of their technical-debt. Technical-debt generally is the same thing as complexity. It's easy to put in one more 'if' statement, and hack workaround, and small tweak, and tiny feature request, and emergency change, until after awhile you have the classic spaghetti code that no one can add anything to, or fix bugs in without breaking something else. That's technical-debt, and it's why I'm such a pain-in-the-ass about discouraging complexity. By the far the biggest challenge I see in my consulting jobs is that creeping complexity.[/quote] Ok, now I have a full picture. You are a rare specimen, you know that :) ?
bo3b said:Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor.

We could also use hard-links, but all of this is pretty small wins compared to other stuff we can spend time upon. If there is a decent offline/non-tool workaround I still think we are better served to use those.


I'm sure you've all heard of "technical-debt". I'm working as a consultant, and I typically come into organizations that are actually frozen in place because of their technical-debt. Technical-debt generally is the same thing as complexity. It's easy to put in one more 'if' statement, and hack workaround, and small tweak, and tiny feature request, and emergency change, until after awhile you have the classic spaghetti code that no one can add anything to, or fix bugs in without breaking something else. That's technical-debt, and it's why I'm such a pain-in-the-ass about discouraging complexity.

By the far the biggest challenge I see in my consulting jobs is that creeping complexity.


Ok, now I have a full picture. You are a rare specimen, you know that :) ?

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/02/2015 04:16 PM   
[quote="bo3b"]Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor.[/quote]Zero effort for us - sounds good :)
bo3b said:Actually, I was thinking it would be the other way around. We don't add complexity and more weirdness to the already weird reloading/loading code, the end-user would just use shortcuts as their way of managing the details. So, a sub-folder named Shadows has shortcuts to all the shaders being set up as Shadow fixes, and double clicks would open them directly in the editor.
Zero effort for us - sounds good :)

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

Posted 12/03/2015 01:09 AM   
Shortcuts method works for me. Sometimes it's difficult to accept the simplest solution :)
Shortcuts method works for me. Sometimes it's difficult to accept the simplest solution :)

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/03/2015 12:01 PM   
Allow me go back to that unfortunate water shader with a broken mask. Adding the centriod modifiers or exporting the shader with the latest 3DM didn't change much. I found one thing though. When I comment the line 134 which you can see below it works as intended. [code] r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0); [/code] This line looks a bit suspicious to me, or maybe it's just my lack of knowledge of the asm code. Would you confirm please if the asm line below really should be looking like the above HLSL code? [code]iadd r1.y, -r1.y, r1.w[/code] Here is again the full shader code for reference: [code]//water broken mask 2 cbuffer _Globals : register(b0) { float HDRRange : packoffset(c29); float2 AmbientLightMapScale : packoffset(c29.y); float4 normalParams1 : packoffset(c30); float4 normalParams2 : packoffset(c31); float4 normalParams3 : packoffset(c32); float4 normalParams4 : packoffset(c33); float timer : packoffset(c34); float3 shoreColour : packoffset(c34.y); float4 shoreParams1 : packoffset(c35); float3 shoreParams2 : packoffset(c36); float4 screenProj : packoffset(c37); float4 fresnelParams : packoffset(c38); float4 horizonColour : packoffset(c39); float4 nadirColour : packoffset(c40); float4 interactiveParams1 : packoffset(c41); float4 interactiveParams5 : packoffset(c42); float4 waterShadowBlend : packoffset(c43); float4 decodeParam : packoffset(c44); float4 sparkleParams : packoffset(c45); float4 sparkleParams2 : packoffset(c46); float blendValue : packoffset(c47); float4 specularParams : packoffset(c48); float4 waveParams : packoffset(c49); float4 interactiveParams2 : packoffset(c50); float4 interactiveParams3 : packoffset(c51); float4 interactiveParams4 : packoffset(c52); } cbuffer RenderTargetConstantBuffer : register(b2) { float4 viewportDimensions : packoffset(c0); } cbuffer CameraParamsConstantBuffer : register(b3) { float4x4 projection : packoffset(c0); float4x4 viewProjection : packoffset(c4); row_major float3x4 view : packoffset(c8); row_major float3x4 viewI : packoffset(c11); float3 eyePositionWS : packoffset(c14); float4x4 inverseProj : packoffset(c15); bool leftEye : packoffset(c19); bool padding3[3] : packoffset(c20); } cbuffer PerFrameConstantBuffer : register(b1) { float4 colorBufferEncodingParams : packoffset(c0); float4 envMapEncodingParams : packoffset(c1); float4 velocityEncodingParams : packoffset(c2); float4 snowEffectsParam2 : packoffset(c3); float4 sunDirectionAndTime : packoffset(c4); float4 sunColour : packoffset(c5); float4 skylightColour : packoffset(c6); float4 ambientOcclusionScales : packoffset(c7); float4 backlightColour : packoffset(c8); float4 specularScales : packoffset(c9); float3 specularDirection : packoffset(c10); float4 specularColourAndMultiplier : packoffset(c11); float4 fogColour : packoffset(c12); float4 fogParams : packoffset(c13); float4 hazeParams : packoffset(c14); float4 hazeParams2 : packoffset(c15); float4 nightLightmapParam1 : packoffset(c16); float4 nightLightmapParam2 : packoffset(c17); float4 wetLightingParam : packoffset(c18); float4 snowEffectsParam : packoffset(c19); float4 ambientColour : packoffset(c20); float4 shadowBlend : packoffset(c21); float4 maskParams : packoffset(c22); float4 deferredSpecularParams : packoffset(c23); } SamplerState TWaterRippleMap_s : register(s0); SamplerState TPreviousWaterRippleMap_s : register(s1); SamplerState TNormalMap_s : register(s2); SamplerState DepthMap_s : register(s3); SamplerState ReflectionMap_s : register(s4); SamplerState ReflectionMap2_s : register(s5); SamplerState TMaskMap_s : register(s6); SamplerState TWaveFront_s : register(s7); SamplerState TShadowMask_s : register(s10); Texture2D<float4> DepthMap : register(t0); Texture2D<float4> TWaterRippleMap : register(t1); Texture2D<float4> TPreviousWaterRippleMap : register(t2); Texture2D<float4> TNormalMap : register(t3); Texture2D<float4> ReflectionMap : register(t4); Texture2D<float4> ReflectionMap2 : register(t5); Texture2D<float4> TShadowMask : register(t6); Texture2D<float4> TMaskMap : register(t7); Texture2D<float4> TWaveFront : register(t8); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( float4 v0 : SV_Position0, linear float4 v1 : COLOR1, float4 v2 : TEXCOORD0, float4 v3 : TEXCOORD1, linear centroid float4 v4 : TEXCOORD2, linear centroid float4 v5 : TEXCOORD3, linear centroid float4 v6 : TEXCOORD4, linear centroid float4 v7 : TEXCOORD5, linear float4 v8 : TEXCOORD6, linear centroid float4 v9 : TEXCOORD7, out float4 o0 : SV_Target0) { float4 r0,r1,r2,r3,r4,r5; uint4 bitmask, uiDest; float4 fDest; r0.xy = TWaterRippleMap.Sample(TWaterRippleMap_s, v9.xy).yz; r0.zw = TPreviousWaterRippleMap.Sample(TPreviousWaterRippleMap_s, v9.xy).yz; r0.xy = r0.xy + -r0.zw; r0.xy = blendValue * r0.xy + r0.zw; r0.xy = float2(0.00196078443,0.00196078443) + r0.xy; r0.xy = r0.xy * float2(2,2) + float2(-1,-1); r1.xy = v8.xy / v8.ww; r1.z = 1 + -r1.y; r0.z = DepthMap.Sample(DepthMap_s, r1.xz).x; r0.z = screenProj.z + r0.z; r0.z = screenProj.w / r0.z; r0.w = v9.z + -r0.z; r0.z = -v9.z + r0.z; r0.z = saturate(waveParams.w * abs(r0.z)); r1.y = 0.100000001 + r0.w; r0.w = dot(r0.ww, interactiveParams1.zz); r1.w = 0 < r1.y; r1.y = r1.y < 0; r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0); r1.y = (int)r1.y; r1.y = saturate(r1.y); r1.w = min(0, -r0.w); r0.w = saturate(r0.w); r0.w = max(r1.y, r0.w); r1.w = exp2(r1.w); r1.w = 1 + -r1.w; r1.y = max(r1.y, r1.w); r0.xy = r1.yy * r0.xy; r2.xy = interactiveParams5.xx * r0.xy; r0.xy = interactiveParams1.xx * r0.xy; r0.xy = max(float2(-1,-1), r0.xy); r0.xy = min(float2(1,1), r0.xy); r0.xy = interactiveParams1.yy * r0.xy; r3.xyzw = specularParams.wwww * normalParams2.xxyy; r3.xyzw = r2.xyxy / r3.xyzw; r2.xy = r2.xy / normalParams2.zz; r2.xy = v6.xy + r2.xy; r2.xyz = TNormalMap.Sample(TNormalMap_s, r2.xy).xyz; r2.xyz = r2.xzy * float3(2,2,2) + float3(-1,-1,-1); r3.xyzw = v5.xyzw + r3.xyzw; r4.xyz = TNormalMap.Sample(TNormalMap_s, r3.zw).xyz; r3.xyz = TNormalMap.Sample(TNormalMap_s, r3.xy).xyz; r3.xyz = r3.xzy * float3(2,2,2) + float3(-1,-1,-1); r4.xyz = r4.xzy * float3(2,2,2) + float3(-1,-1,-1); r4.xyz = normalParams3.yyy * r4.xyz; r3.xyz = normalParams3.xxx * r3.xyz + r4.xyz; r2.xyz = normalParams3.zzz * r2.xyz + r3.xyz; r2.xz = r0.xy * r2.yy + r2.xz; r0.x = dot(r2.xyz, r2.xyz); r0.x = rsqrt(r0.x); r2.xyz = r2.xyz * r0.xxx; r2.xyz = normalParams3.www * r2.xyz; r3.xyz = -eyePositionWS.xyz + v7.xyz; r0.x = dot(r3.xyz, r3.xyz); r0.y = sqrt(r0.x); r0.x = saturate(r0.x * shadowBlend.x + shadowBlend.y); r3.xyz = r3.xyz / r0.yyy; r0.y = -sparkleParams2.z + r0.y; r1.w = dot(r3.xyz, r2.xyz); r1.w = saturate(1 + r1.w); r3.xyz = -nadirColour.xyz + horizonColour.xyz; r3.xyz = r1.www * r3.xyz + nadirColour.xyz; r4.xyz = shoreColour.xyz + -r3.xyz; r3.xyz = v4.www * r4.xyz + r3.xyz; r2.y = saturate(maskParams.w); r2.w = 1 + -r2.y; r0.x = r2.w * r0.x; r4.y = v8.w + -v8.y; r4.zw = maskParams.xx * viewportDimensions.zw; r4.x = v8.x; r4.xy = v8.ww * r4.zw + r4.xy; r4.xy = r4.xy / v8.ww; r4.xyzw = TShadowMask.Sample(TShadowMask_s, r4.xy).xyzw; r2.w = 1 + -r4.x; r2.w = r2.y * r2.w + r4.x; r3.w = 1 + -r2.w; r0.x = r0.x * r3.w + r2.w; r2.w = 1 + -r0.x; r0.x = r0.z * r2.w + r0.x; r4.xyz = maskParams.www * r4.yzw + -r0.xxx; r4.xyz = r2.yyy * r4.xyz + r0.xxx; r5.xyz = r4.xyz * r3.xyz; r3.xyz = -r3.xyz * r4.xyz + shoreParams2.zzz; r4.xyzw = normalParams4.xyzw + v7.xzxz; r4.xyzw = sparkleParams2.xxxx * r4.xyzw; r4.xyzw = specularParams.wwww * r4.xyzw; r4.xyzw = float4(0.0500000007,0.0500000007,0.0500000007,0.0500000007) * r4.xyzw; r0.x = TMaskMap.Sample(TMaskMap_s, r4.xy).x; r0.z = TMaskMap.Sample(TMaskMap_s, r4.zw).z; r0.x = r0.x + r0.z; r4.xyzw = shoreParams1.xyzw + v7.xzxz; r4.xyzw = shoreParams2.xxyy * r4.xyzw; r4.xyzw = float4(0.0500000007,0.0500000007,0.0500000007,0.0500000007) * r4.xyzw; r2.yw = TWaveFront.Sample(TWaveFront_s, r4.xy).yz; r4.xy = TWaveFront.Sample(TWaveFront_s, r4.zw).yz; r0.z = r4.y + r2.w; r2.y = r4.x * r2.y; r0.z = v4.w * r0.z; r0.z = r0.x * r0.z; r2.w = r2.y * r0.z; r0.z = -r2.y * r0.z + 1; r3.xyz = r2.www * r3.xyz + r5.xyz; r2.y = interactiveParams4.z * 0.300000012; r2.w = interactiveParams4.w * 0.300000012 + -r2.y; r2.y = r1.w * r2.w + r2.y; r1.w = log2(r1.w); r1.w = fresnelParams.z * r1.w; r1.w = exp2(r1.w); r1.xz = saturate(r2.xz * r2.yy + r1.xz); r2.xyzw = ReflectionMap.Sample(ReflectionMap_s, r1.xz).xyzw; r4.xyzw = ReflectionMap2.Sample(ReflectionMap2_s, r1.xz).xyzw; r2.xyzw = leftEye ? r2.xyzw : r4.xyzw; r4.xyz = colorBufferEncodingParams.yyy * r2.xyz; r2.xyz = r2.xyz * colorBufferEncodingParams.www + float3(1,1,1); r2.xyz = r4.xyz / r2.xyz; r2.xyz = r2.xyz + -r3.xyz; r1.x = fresnelParams.y + -fresnelParams.x; r1.x = r1.w * r1.x + fresnelParams.x; r1.x = r1.x * r2.w; r1.x = r1.x * r0.z; r1.xzw = r1.xxx * r2.xyz + r3.xyz; r2.x = sparkleParams2.w + -sparkleParams2.z; r0.y = saturate(r0.y / r2.x); r0.y = 1 + -r0.y; r0.y = sparkleParams.x * r0.y; r0.x = r0.y * r0.x; r2.xy = sparkleParams.yy * v7.zx; r2.xy = float2(0.0500000007,0.0500000007) * r2.xy; r2.zw = waveParams.xy * timer; r3.xy = r2.zw * normalParams1.ww + r2.yx; r2.xy = r2.zw * normalParams2.ww + r2.xy; r0.y = TMaskMap.Sample(TMaskMap_s, r2.xy).y; r2.x = TMaskMap.Sample(TMaskMap_s, r3.xy).y; r0.x = r2.x * r0.x; r0.x = r0.x * r0.y; r0.xyz = r0.xxx * r0.zzz + r1.xzw; r0.xyz = r0.xyz * v1.www + v1.xyz; r1.xzw = colorBufferEncodingParams.zzz * r0.xyz; r0.xyz = r0.xyz * colorBufferEncodingParams.xxx + float3(1,1,1); o0.xyz = r1.xzw / r0.xyz; r0.x = saturate(v9.w); r0.x = min(r0.x, r1.y); o0.w = r0.x * r0.w; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // using 3Dmigoto v1.2.13 on Thu Dec 03 15:48:17 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float HDRRange; // Offset: 464 Size: 4 [unused] // float2 AmbientLightMapScale; // Offset: 468 Size: 8 [unused] // float4 normalParams1; // Offset: 480 Size: 16 // float4 normalParams2; // Offset: 496 Size: 16 // float4 normalParams3; // Offset: 512 Size: 16 // float4 normalParams4; // Offset: 528 Size: 16 // float timer; // Offset: 544 Size: 4 // float3 shoreColour; // Offset: 548 Size: 12 // float4 shoreParams1; // Offset: 560 Size: 16 // float3 shoreParams2; // Offset: 576 Size: 12 // float4 screenProj; // Offset: 592 Size: 16 // float4 fresnelParams; // Offset: 608 Size: 16 // float4 horizonColour; // Offset: 624 Size: 16 // float4 nadirColour; // Offset: 640 Size: 16 // float4 interactiveParams1; // Offset: 656 Size: 16 // float4 interactiveParams5; // Offset: 672 Size: 16 // float4 waterShadowBlend; // Offset: 688 Size: 16 [unused] // float4 decodeParam; // Offset: 704 Size: 16 [unused] // float4 sparkleParams; // Offset: 720 Size: 16 // float4 sparkleParams2; // Offset: 736 Size: 16 // float blendValue; // Offset: 752 Size: 4 // float4 specularParams; // Offset: 768 Size: 16 // float4 waveParams; // Offset: 784 Size: 16 // float4 interactiveParams2; // Offset: 800 Size: 16 [unused] // float4 interactiveParams3; // Offset: 816 Size: 16 [unused] // float4 interactiveParams4; // Offset: 832 Size: 16 // // } // // cbuffer RenderTargetConstantBuffer // { // // float4 viewportDimensions; // Offset: 0 Size: 16 // // } // // cbuffer CameraParamsConstantBuffer // { // // float4x4 projection; // Offset: 0 Size: 64 [unused] // float4x4 viewProjection; // Offset: 64 Size: 64 [unused] // row_major float3x4 view; // Offset: 128 Size: 48 [unused] // row_major float3x4 viewI; // Offset: 176 Size: 48 [unused] // float3 eyePositionWS; // Offset: 224 Size: 12 // float4x4 inverseProj; // Offset: 240 Size: 64 [unused] // bool leftEye; // Offset: 304 Size: 4 // bool padding3[3]; // Offset: 320 Size: 36 [unused] // // } // // cbuffer PerFrameConstantBuffer // { // // float4 colorBufferEncodingParams; // Offset: 0 Size: 16 // float4 envMapEncodingParams; // Offset: 16 Size: 16 [unused] // float4 velocityEncodingParams; // Offset: 32 Size: 16 [unused] // float4 snowEffectsParam2; // Offset: 48 Size: 16 [unused] // float4 sunDirectionAndTime; // Offset: 64 Size: 16 [unused] // float4 sunColour; // Offset: 80 Size: 16 [unused] // float4 skylightColour; // Offset: 96 Size: 16 [unused] // float4 ambientOcclusionScales; // Offset: 112 Size: 16 [unused] // float4 backlightColour; // Offset: 128 Size: 16 [unused] // float4 specularScales; // Offset: 144 Size: 16 [unused] // float3 specularDirection; // Offset: 160 Size: 12 [unused] // float4 specularColourAndMultiplier;// Offset: 176 Size: 16 [unused] // float4 fogColour; // Offset: 192 Size: 16 [unused] // float4 fogParams; // Offset: 208 Size: 16 [unused] // float4 hazeParams; // Offset: 224 Size: 16 [unused] // float4 hazeParams2; // Offset: 240 Size: 16 [unused] // float4 nightLightmapParam1; // Offset: 256 Size: 16 [unused] // float4 nightLightmapParam2; // Offset: 272 Size: 16 [unused] // float4 wetLightingParam; // Offset: 288 Size: 16 [unused] // float4 snowEffectsParam; // Offset: 304 Size: 16 [unused] // float4 ambientColour; // Offset: 320 Size: 16 [unused] // float4 shadowBlend; // Offset: 336 Size: 16 // float4 maskParams; // Offset: 352 Size: 16 // float4 deferredSpecularParams; // Offset: 368 Size: 16 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // TWaterRippleMap sampler NA NA 0 1 // TPreviousWaterRippleMap sampler NA NA 1 1 // TNormalMap sampler NA NA 2 1 // DepthMap sampler NA NA 3 1 // ReflectionMap sampler NA NA 4 1 // ReflectionMap2 sampler NA NA 5 1 // TMaskMap sampler NA NA 6 1 // TWaveFront sampler NA NA 7 1 // TShadowMask sampler NA NA 10 1 // DepthMap texture float4 2d 0 1 // TWaterRippleMap texture float4 2d 1 1 // TPreviousWaterRippleMap texture float4 2d 2 1 // TNormalMap texture float4 2d 3 1 // ReflectionMap texture float4 2d 4 1 // ReflectionMap2 texture float4 2d 5 1 // TShadowMask texture float4 2d 6 1 // TMaskMap texture float4 2d 7 1 // TWaveFront texture float4 2d 8 1 // $Globals cbuffer NA NA 0 1 // PerFrameConstantBuffer cbuffer NA NA 1 1 // RenderTargetConstantBuffer cbuffer NA NA 2 1 // CameraParamsConstantBuffer cbuffer NA NA 3 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float // COLOR 1 xyzw 1 NONE float xyzw // TEXCOORD 0 xyzw 2 NONE float // TEXCOORD 1 xyzw 3 NONE float // TEXCOORD 2 xyzw 4 NONE float w // TEXCOORD 3 xyzw 5 NONE float xyzw // TEXCOORD 4 xyzw 6 NONE float xy // TEXCOORD 5 xyz 7 NONE float xyz // TEXCOORD 6 xyzw 8 NONE float xy w // TEXCOORD 7 xyzw 9 NONE float xyzw // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[53], immediateIndexed dcl_constantbuffer cb2[1], immediateIndexed dcl_constantbuffer cb3[20], immediateIndexed dcl_constantbuffer cb1[23], immediateIndexed dcl_sampler s0, mode_default dcl_sampler s1, mode_default dcl_sampler s2, mode_default dcl_sampler s3, mode_default dcl_sampler s4, mode_default dcl_sampler s5, mode_default dcl_sampler s6, mode_default dcl_sampler s7, mode_default dcl_sampler s10, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texture2d (float,float,float,float) t1 dcl_resource_texture2d (float,float,float,float) t2 dcl_resource_texture2d (float,float,float,float) t3 dcl_resource_texture2d (float,float,float,float) t4 dcl_resource_texture2d (float,float,float,float) t5 dcl_resource_texture2d (float,float,float,float) t6 dcl_resource_texture2d (float,float,float,float) t7 dcl_resource_texture2d (float,float,float,float) t8 dcl_input_ps linear v1.xyzw dcl_input_ps linear centroid v4.w dcl_input_ps linear centroid v5.xyzw dcl_input_ps linear centroid v6.xy dcl_input_ps linear centroid v7.xyz dcl_input_ps linear v8.xyw dcl_input_ps linear centroid v9.xyzw dcl_output o0.xyzw dcl_temps 6 sample_indexable(texture2d)(float,float,float,float) r0.xy, v9.xyxx, t1.yzxw, s0 sample_indexable(texture2d)(float,float,float,float) r0.zw, v9.xyxx, t2.xwyz, s1 add r0.xy, -r0.zwzz, r0.xyxx mad r0.xy, cb0[47].xxxx, r0.xyxx, r0.zwzz add r0.xy, r0.xyxx, l(0.00196078443, 0.00196078443, 0.000000, 0.000000) mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000) div r1.xy, v8.xyxx, v8.wwww add r1.z, -r1.y, l(1.000000) sample_indexable(texture2d)(float,float,float,float) r0.z, r1.xzxx, t0.yzxw, s3 add r0.z, r0.z, cb0[37].z div r0.z, cb0[37].w, r0.z add r0.w, -r0.z, v9.z add r0.z, r0.z, -v9.z mul_sat r0.z, |r0.z|, cb0[49].w add r1.y, r0.w, l(0.100000) dp2 r0.w, r0.wwww, cb0[41].zzzz lt r1.w, l(0.000000), r1.y lt r1.y, r1.y, l(0.000000) iadd r1.y, -r1.y, r1.w itof r1.y, r1.y mov_sat r1.y, r1.y min r1.w, -r0.w, l(0.000000) mov_sat r0.w, r0.w max r0.w, r0.w, r1.y exp r1.w, r1.w add r1.w, -r1.w, l(1.000000) max r1.y, r1.w, r1.y mul r0.xy, r0.xyxx, r1.yyyy mul r2.xy, r0.xyxx, cb0[42].xxxx mul r0.xy, r0.xyxx, cb0[41].xxxx max r0.xy, r0.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000) min r0.xy, r0.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) mul r0.xy, r0.xyxx, cb0[41].yyyy mul r3.xyzw, cb0[31].xxyy, cb0[48].wwww div r3.xyzw, r2.xyxy, r3.xyzw div r2.xy, r2.xyxx, cb0[31].zzzz add r2.xy, r2.xyxx, v6.xyxx sample_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t3.xyzw, s2 mad r2.xyz, r2.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) add r3.xyzw, r3.xyzw, v5.xyzw sample_indexable(texture2d)(float,float,float,float) r4.xyz, r3.zwzz, t3.xyzw, s2 sample_indexable(texture2d)(float,float,float,float) r3.xyz, r3.xyxx, t3.xyzw, s2 mad r3.xyz, r3.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) mad r4.xyz, r4.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) mul r4.xyz, r4.xyzx, cb0[32].yyyy mad r3.xyz, cb0[32].xxxx, r3.xyzx, r4.xyzx mad r2.xyz, cb0[32].zzzz, r2.xyzx, r3.xyzx mad r2.xz, r0.xxyx, r2.yyyy, r2.xxzx dp3 r0.x, r2.xyzx, r2.xyzx rsq r0.x, r0.x mul r2.xyz, r0.xxxx, r2.xyzx mul r2.xyz, r2.xyzx, cb0[32].wwww add r3.xyz, v7.xyzx, -cb3[14].xyzx dp3 r0.x, r3.xyzx, r3.xyzx sqrt r0.y, r0.x mad_sat r0.x, r0.x, cb1[21].x, cb1[21].y div r3.xyz, r3.xyzx, r0.yyyy add r0.y, r0.y, -cb0[46].z dp3 r1.w, r3.xyzx, r2.xyzx add_sat r1.w, r1.w, l(1.000000) add r3.xyz, cb0[39].xyzx, -cb0[40].xyzx mad r3.xyz, r1.wwww, r3.xyzx, cb0[40].xyzx add r4.xyz, -r3.xyzx, cb0[34].yzwy mad r3.xyz, v4.wwww, r4.xyzx, r3.xyzx mov_sat r2.y, cb1[22].w add r2.w, -r2.y, l(1.000000) mul r0.x, r0.x, r2.w add r4.y, -v8.y, v8.w mul r4.zw, cb2[0].zzzw, cb1[22].xxxx mov r4.x, v8.x mad r4.xy, v8.wwww, r4.zwzz, r4.xyxx div r4.xy, r4.xyxx, v8.wwww sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r4.xyxx, t6.xyzw, s10 add r2.w, -r4.x, l(1.000000) mad r2.w, r2.y, r2.w, r4.x add r3.w, -r2.w, l(1.000000) mad r0.x, r0.x, r3.w, r2.w add r2.w, -r0.x, l(1.000000) mad r0.x, r0.z, r2.w, r0.x mad r4.xyz, cb1[22].wwww, r4.yzwy, -r0.xxxx mad r4.xyz, r2.yyyy, r4.xyzx, r0.xxxx mul r5.xyz, r3.xyzx, r4.xyzx mad r3.xyz, -r3.xyzx, r4.xyzx, cb0[36].zzzz add r4.xyzw, v7.xzxz, cb0[33].xyzw mul r4.xyzw, r4.xyzw, cb0[46].xxxx mul r4.xyzw, r4.xyzw, cb0[48].wwww mul r4.xyzw, r4.xyzw, l(0.050000, 0.050000, 0.050000, 0.050000) sample_indexable(texture2d)(float,float,float,float) r0.x, r4.xyxx, t7.xyzw, s6 sample_indexable(texture2d)(float,float,float,float) r0.z, r4.zwzz, t7.xyzw, s6 add r0.x, r0.z, r0.x add r4.xyzw, v7.xzxz, cb0[35].xyzw mul r4.xyzw, r4.xyzw, cb0[36].xxyy mul r4.xyzw, r4.xyzw, l(0.050000, 0.050000, 0.050000, 0.050000) sample_indexable(texture2d)(float,float,float,float) r2.yw, r4.xyxx, t8.xywz, s7 sample_indexable(texture2d)(float,float,float,float) r4.xy, r4.zwzz, t8.yzxw, s7 add r0.z, r2.w, r4.y mul r2.y, r2.y, r4.x mul r0.z, r0.z, v4.w mul r0.z, r0.z, r0.x mul r2.w, r0.z, r2.y mad r0.z, -r2.y, r0.z, l(1.000000) mad r3.xyz, r2.wwww, r3.xyzx, r5.xyzx mul r2.y, l(0.300000), cb0[52].z mad r2.w, cb0[52].w, l(0.300000), -r2.y mad r2.y, r1.w, r2.w, r2.y log r1.w, r1.w mul r1.w, r1.w, cb0[38].z exp r1.w, r1.w mad_sat r1.xz, r2.xxzx, r2.yyyy, r1.xxzx sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xzxx, t4.xyzw, s4 sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r1.xzxx, t5.xyzw, s5 movc r2.xyzw, cb3[19].xxxx, r2.xyzw, r4.xyzw mul r4.xyz, r2.xyzx, cb1[0].yyyy mad r2.xyz, r2.xyzx, cb1[0].wwww, l(1.000000, 1.000000, 1.000000, 0.000000) div r2.xyz, r4.xyzx, r2.xyzx add r2.xyz, -r3.xyzx, r2.xyzx add r1.x, -cb0[38].x, cb0[38].y mad r1.x, r1.w, r1.x, cb0[38].x mul r1.x, r2.w, r1.x mul r1.x, r0.z, r1.x mad r1.xzw, r1.xxxx, r2.xxyz, r3.xxyz add r2.x, -cb0[46].z, cb0[46].w div_sat r0.y, r0.y, r2.x add r0.y, -r0.y, l(1.000000) mul r0.y, r0.y, cb0[45].x mul r0.x, r0.x, r0.y mul r2.xy, v7.zxzz, cb0[45].yyyy mul r2.xy, r2.xyxx, l(0.050000, 0.050000, 0.000000, 0.000000) mul r2.zw, cb0[34].xxxx, cb0[49].xxxy mad r3.xy, r2.zwzz, cb0[30].wwww, r2.yxyy mad r2.xy, r2.zwzz, cb0[31].wwww, r2.xyxx sample_indexable(texture2d)(float,float,float,float) r0.y, r2.xyxx, t7.xyzw, s6 sample_indexable(texture2d)(float,float,float,float) r2.x, r3.xyxx, t7.yxzw, s6 mul r0.x, r0.x, r2.x mul r0.x, r0.y, r0.x mad r0.xyz, r0.xxxx, r0.zzzz, r1.xzwx mad r0.xyz, r0.xyzx, v1.wwww, v1.xyzx mul r1.xzw, r0.xxyz, cb1[0].zzzz mad r0.xyz, r0.xyzx, cb1[0].xxxx, l(1.000000, 1.000000, 1.000000, 0.000000) div o0.xyz, r1.xzwx, r0.xyzx mov_sat r0.x, v9.w min r0.x, r1.y, r0.x mul o0.w, r0.w, r0.x ret // Approximately 144 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ [/code]
Allow me go back to that unfortunate water shader with a broken mask. Adding the centriod modifiers or exporting the shader with the latest 3DM didn't change much. I found one thing though. When I comment the line 134 which you can see below it works as intended.

r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0);


This line looks a bit suspicious to me, or maybe it's just my lack of knowledge of the asm code.
Would you confirm please if the asm line below really should be looking like the above HLSL code?

iadd r1.y, -r1.y, r1.w



Here is again the full shader code for reference:

//water broken mask 2

cbuffer _Globals : register(b0)
{
float HDRRange : packoffset(c29);
float2 AmbientLightMapScale : packoffset(c29.y);
float4 normalParams1 : packoffset(c30);
float4 normalParams2 : packoffset(c31);
float4 normalParams3 : packoffset(c32);
float4 normalParams4 : packoffset(c33);
float timer : packoffset(c34);
float3 shoreColour : packoffset(c34.y);
float4 shoreParams1 : packoffset(c35);
float3 shoreParams2 : packoffset(c36);
float4 screenProj : packoffset(c37);
float4 fresnelParams : packoffset(c38);
float4 horizonColour : packoffset(c39);
float4 nadirColour : packoffset(c40);
float4 interactiveParams1 : packoffset(c41);
float4 interactiveParams5 : packoffset(c42);
float4 waterShadowBlend : packoffset(c43);
float4 decodeParam : packoffset(c44);
float4 sparkleParams : packoffset(c45);
float4 sparkleParams2 : packoffset(c46);
float blendValue : packoffset(c47);
float4 specularParams : packoffset(c48);
float4 waveParams : packoffset(c49);
float4 interactiveParams2 : packoffset(c50);
float4 interactiveParams3 : packoffset(c51);
float4 interactiveParams4 : packoffset(c52);
}

cbuffer RenderTargetConstantBuffer : register(b2)
{
float4 viewportDimensions : packoffset(c0);
}

cbuffer CameraParamsConstantBuffer : register(b3)
{
float4x4 projection : packoffset(c0);
float4x4 viewProjection : packoffset(c4);
row_major float3x4 view : packoffset(c8);
row_major float3x4 viewI : packoffset(c11);
float3 eyePositionWS : packoffset(c14);
float4x4 inverseProj : packoffset(c15);
bool leftEye : packoffset(c19);
bool padding3[3] : packoffset(c20);
}

cbuffer PerFrameConstantBuffer : register(b1)
{
float4 colorBufferEncodingParams : packoffset(c0);
float4 envMapEncodingParams : packoffset(c1);
float4 velocityEncodingParams : packoffset(c2);
float4 snowEffectsParam2 : packoffset(c3);
float4 sunDirectionAndTime : packoffset(c4);
float4 sunColour : packoffset(c5);
float4 skylightColour : packoffset(c6);
float4 ambientOcclusionScales : packoffset(c7);
float4 backlightColour : packoffset(c8);
float4 specularScales : packoffset(c9);
float3 specularDirection : packoffset(c10);
float4 specularColourAndMultiplier : packoffset(c11);
float4 fogColour : packoffset(c12);
float4 fogParams : packoffset(c13);
float4 hazeParams : packoffset(c14);
float4 hazeParams2 : packoffset(c15);
float4 nightLightmapParam1 : packoffset(c16);
float4 nightLightmapParam2 : packoffset(c17);
float4 wetLightingParam : packoffset(c18);
float4 snowEffectsParam : packoffset(c19);
float4 ambientColour : packoffset(c20);
float4 shadowBlend : packoffset(c21);
float4 maskParams : packoffset(c22);
float4 deferredSpecularParams : packoffset(c23);
}
SamplerState TWaterRippleMap_s : register(s0);
SamplerState TPreviousWaterRippleMap_s : register(s1);
SamplerState TNormalMap_s : register(s2);
SamplerState DepthMap_s : register(s3);
SamplerState ReflectionMap_s : register(s4);
SamplerState ReflectionMap2_s : register(s5);
SamplerState TMaskMap_s : register(s6);
SamplerState TWaveFront_s : register(s7);
SamplerState TShadowMask_s : register(s10);
Texture2D<float4> DepthMap : register(t0);
Texture2D<float4> TWaterRippleMap : register(t1);
Texture2D<float4> TPreviousWaterRippleMap : register(t2);
Texture2D<float4> TNormalMap : register(t3);
Texture2D<float4> ReflectionMap : register(t4);
Texture2D<float4> ReflectionMap2 : register(t5);
Texture2D<float4> TShadowMask : register(t6);
Texture2D<float4> TMaskMap : register(t7);
Texture2D<float4> TWaveFront : register(t8);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
float4 v0 : SV_Position0,
linear float4 v1 : COLOR1,
float4 v2 : TEXCOORD0,
float4 v3 : TEXCOORD1,
linear centroid float4 v4 : TEXCOORD2,
linear centroid float4 v5 : TEXCOORD3,
linear centroid float4 v6 : TEXCOORD4,
linear centroid float4 v7 : TEXCOORD5,
linear float4 v8 : TEXCOORD6,
linear centroid float4 v9 : TEXCOORD7,
out float4 o0 : SV_Target0)
{
float4 r0,r1,r2,r3,r4,r5;
uint4 bitmask, uiDest;
float4 fDest;

r0.xy = TWaterRippleMap.Sample(TWaterRippleMap_s, v9.xy).yz;
r0.zw = TPreviousWaterRippleMap.Sample(TPreviousWaterRippleMap_s, v9.xy).yz;
r0.xy = r0.xy + -r0.zw;
r0.xy = blendValue * r0.xy + r0.zw;
r0.xy = float2(0.00196078443,0.00196078443) + r0.xy;
r0.xy = r0.xy * float2(2,2) + float2(-1,-1);
r1.xy = v8.xy / v8.ww;
r1.z = 1 + -r1.y;
r0.z = DepthMap.Sample(DepthMap_s, r1.xz).x;
r0.z = screenProj.z + r0.z;
r0.z = screenProj.w / r0.z;
r0.w = v9.z + -r0.z;
r0.z = -v9.z + r0.z;
r0.z = saturate(waveParams.w * abs(r0.z));
r1.y = 0.100000001 + r0.w;
r0.w = dot(r0.ww, interactiveParams1.zz);
r1.w = 0 < r1.y;
r1.y = r1.y < 0;
r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0);
r1.y = (int)r1.y;
r1.y = saturate(r1.y);
r1.w = min(0, -r0.w);
r0.w = saturate(r0.w);
r0.w = max(r1.y, r0.w);
r1.w = exp2(r1.w);
r1.w = 1 + -r1.w;
r1.y = max(r1.y, r1.w);
r0.xy = r1.yy * r0.xy;
r2.xy = interactiveParams5.xx * r0.xy;
r0.xy = interactiveParams1.xx * r0.xy;
r0.xy = max(float2(-1,-1), r0.xy);
r0.xy = min(float2(1,1), r0.xy);
r0.xy = interactiveParams1.yy * r0.xy;
r3.xyzw = specularParams.wwww * normalParams2.xxyy;
r3.xyzw = r2.xyxy / r3.xyzw;
r2.xy = r2.xy / normalParams2.zz;
r2.xy = v6.xy + r2.xy;
r2.xyz = TNormalMap.Sample(TNormalMap_s, r2.xy).xyz;
r2.xyz = r2.xzy * float3(2,2,2) + float3(-1,-1,-1);
r3.xyzw = v5.xyzw + r3.xyzw;
r4.xyz = TNormalMap.Sample(TNormalMap_s, r3.zw).xyz;
r3.xyz = TNormalMap.Sample(TNormalMap_s, r3.xy).xyz;
r3.xyz = r3.xzy * float3(2,2,2) + float3(-1,-1,-1);
r4.xyz = r4.xzy * float3(2,2,2) + float3(-1,-1,-1);
r4.xyz = normalParams3.yyy * r4.xyz;
r3.xyz = normalParams3.xxx * r3.xyz + r4.xyz;
r2.xyz = normalParams3.zzz * r2.xyz + r3.xyz;
r2.xz = r0.xy * r2.yy + r2.xz;
r0.x = dot(r2.xyz, r2.xyz);
r0.x = rsqrt(r0.x);
r2.xyz = r2.xyz * r0.xxx;
r2.xyz = normalParams3.www * r2.xyz;
r3.xyz = -eyePositionWS.xyz + v7.xyz;
r0.x = dot(r3.xyz, r3.xyz);
r0.y = sqrt(r0.x);
r0.x = saturate(r0.x * shadowBlend.x + shadowBlend.y);
r3.xyz = r3.xyz / r0.yyy;
r0.y = -sparkleParams2.z + r0.y;
r1.w = dot(r3.xyz, r2.xyz);
r1.w = saturate(1 + r1.w);
r3.xyz = -nadirColour.xyz + horizonColour.xyz;
r3.xyz = r1.www * r3.xyz + nadirColour.xyz;
r4.xyz = shoreColour.xyz + -r3.xyz;
r3.xyz = v4.www * r4.xyz + r3.xyz;
r2.y = saturate(maskParams.w);
r2.w = 1 + -r2.y;
r0.x = r2.w * r0.x;
r4.y = v8.w + -v8.y;
r4.zw = maskParams.xx * viewportDimensions.zw;
r4.x = v8.x;
r4.xy = v8.ww * r4.zw + r4.xy;
r4.xy = r4.xy / v8.ww;
r4.xyzw = TShadowMask.Sample(TShadowMask_s, r4.xy).xyzw;
r2.w = 1 + -r4.x;
r2.w = r2.y * r2.w + r4.x;
r3.w = 1 + -r2.w;
r0.x = r0.x * r3.w + r2.w;
r2.w = 1 + -r0.x;
r0.x = r0.z * r2.w + r0.x;
r4.xyz = maskParams.www * r4.yzw + -r0.xxx;
r4.xyz = r2.yyy * r4.xyz + r0.xxx;
r5.xyz = r4.xyz * r3.xyz;
r3.xyz = -r3.xyz * r4.xyz + shoreParams2.zzz;
r4.xyzw = normalParams4.xyzw + v7.xzxz;
r4.xyzw = sparkleParams2.xxxx * r4.xyzw;
r4.xyzw = specularParams.wwww * r4.xyzw;
r4.xyzw = float4(0.0500000007,0.0500000007,0.0500000007,0.0500000007) * r4.xyzw;
r0.x = TMaskMap.Sample(TMaskMap_s, r4.xy).x;
r0.z = TMaskMap.Sample(TMaskMap_s, r4.zw).z;
r0.x = r0.x + r0.z;
r4.xyzw = shoreParams1.xyzw + v7.xzxz;
r4.xyzw = shoreParams2.xxyy * r4.xyzw;
r4.xyzw = float4(0.0500000007,0.0500000007,0.0500000007,0.0500000007) * r4.xyzw;
r2.yw = TWaveFront.Sample(TWaveFront_s, r4.xy).yz;
r4.xy = TWaveFront.Sample(TWaveFront_s, r4.zw).yz;
r0.z = r4.y + r2.w;
r2.y = r4.x * r2.y;
r0.z = v4.w * r0.z;
r0.z = r0.x * r0.z;
r2.w = r2.y * r0.z;
r0.z = -r2.y * r0.z + 1;
r3.xyz = r2.www * r3.xyz + r5.xyz;
r2.y = interactiveParams4.z * 0.300000012;
r2.w = interactiveParams4.w * 0.300000012 + -r2.y;
r2.y = r1.w * r2.w + r2.y;
r1.w = log2(r1.w);
r1.w = fresnelParams.z * r1.w;
r1.w = exp2(r1.w);
r1.xz = saturate(r2.xz * r2.yy + r1.xz);
r2.xyzw = ReflectionMap.Sample(ReflectionMap_s, r1.xz).xyzw;
r4.xyzw = ReflectionMap2.Sample(ReflectionMap2_s, r1.xz).xyzw;
r2.xyzw = leftEye ? r2.xyzw : r4.xyzw;
r4.xyz = colorBufferEncodingParams.yyy * r2.xyz;
r2.xyz = r2.xyz * colorBufferEncodingParams.www + float3(1,1,1);
r2.xyz = r4.xyz / r2.xyz;
r2.xyz = r2.xyz + -r3.xyz;
r1.x = fresnelParams.y + -fresnelParams.x;
r1.x = r1.w * r1.x + fresnelParams.x;
r1.x = r1.x * r2.w;
r1.x = r1.x * r0.z;
r1.xzw = r1.xxx * r2.xyz + r3.xyz;
r2.x = sparkleParams2.w + -sparkleParams2.z;
r0.y = saturate(r0.y / r2.x);
r0.y = 1 + -r0.y;
r0.y = sparkleParams.x * r0.y;
r0.x = r0.y * r0.x;
r2.xy = sparkleParams.yy * v7.zx;
r2.xy = float2(0.0500000007,0.0500000007) * r2.xy;
r2.zw = waveParams.xy * timer;
r3.xy = r2.zw * normalParams1.ww + r2.yx;
r2.xy = r2.zw * normalParams2.ww + r2.xy;
r0.y = TMaskMap.Sample(TMaskMap_s, r2.xy).y;
r2.x = TMaskMap.Sample(TMaskMap_s, r3.xy).y;
r0.x = r2.x * r0.x;
r0.x = r0.x * r0.y;
r0.xyz = r0.xxx * r0.zzz + r1.xzw;
r0.xyz = r0.xyz * v1.www + v1.xyz;
r1.xzw = colorBufferEncodingParams.zzz * r0.xyz;
r0.xyz = r0.xyz * colorBufferEncodingParams.xxx + float3(1,1,1);
o0.xyz = r1.xzw / r0.xyz;
r0.x = saturate(v9.w);
r0.x = min(r0.x, r1.y);
o0.w = r0.x * r0.w;
return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// using 3Dmigoto v1.2.13 on Thu Dec 03 15:48:17 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float HDRRange; // Offset: 464 Size: 4 [unused]
// float2 AmbientLightMapScale; // Offset: 468 Size: 8 [unused]
// float4 normalParams1; // Offset: 480 Size: 16
// float4 normalParams2; // Offset: 496 Size: 16
// float4 normalParams3; // Offset: 512 Size: 16
// float4 normalParams4; // Offset: 528 Size: 16
// float timer; // Offset: 544 Size: 4
// float3 shoreColour; // Offset: 548 Size: 12
// float4 shoreParams1; // Offset: 560 Size: 16
// float3 shoreParams2; // Offset: 576 Size: 12
// float4 screenProj; // Offset: 592 Size: 16
// float4 fresnelParams; // Offset: 608 Size: 16
// float4 horizonColour; // Offset: 624 Size: 16
// float4 nadirColour; // Offset: 640 Size: 16
// float4 interactiveParams1; // Offset: 656 Size: 16
// float4 interactiveParams5; // Offset: 672 Size: 16
// float4 waterShadowBlend; // Offset: 688 Size: 16 [unused]
// float4 decodeParam; // Offset: 704 Size: 16 [unused]
// float4 sparkleParams; // Offset: 720 Size: 16
// float4 sparkleParams2; // Offset: 736 Size: 16
// float blendValue; // Offset: 752 Size: 4
// float4 specularParams; // Offset: 768 Size: 16
// float4 waveParams; // Offset: 784 Size: 16
// float4 interactiveParams2; // Offset: 800 Size: 16 [unused]
// float4 interactiveParams3; // Offset: 816 Size: 16 [unused]
// float4 interactiveParams4; // Offset: 832 Size: 16
//
// }
//
// cbuffer RenderTargetConstantBuffer
// {
//
// float4 viewportDimensions; // Offset: 0 Size: 16
//
// }
//
// cbuffer CameraParamsConstantBuffer
// {
//
// float4x4 projection; // Offset: 0 Size: 64 [unused]
// float4x4 viewProjection; // Offset: 64 Size: 64 [unused]
// row_major float3x4 view; // Offset: 128 Size: 48 [unused]
// row_major float3x4 viewI; // Offset: 176 Size: 48 [unused]
// float3 eyePositionWS; // Offset: 224 Size: 12
// float4x4 inverseProj; // Offset: 240 Size: 64 [unused]
// bool leftEye; // Offset: 304 Size: 4
// bool padding3[3]; // Offset: 320 Size: 36 [unused]
//
// }
//
// cbuffer PerFrameConstantBuffer
// {
//
// float4 colorBufferEncodingParams; // Offset: 0 Size: 16
// float4 envMapEncodingParams; // Offset: 16 Size: 16 [unused]
// float4 velocityEncodingParams; // Offset: 32 Size: 16 [unused]
// float4 snowEffectsParam2; // Offset: 48 Size: 16 [unused]
// float4 sunDirectionAndTime; // Offset: 64 Size: 16 [unused]
// float4 sunColour; // Offset: 80 Size: 16 [unused]
// float4 skylightColour; // Offset: 96 Size: 16 [unused]
// float4 ambientOcclusionScales; // Offset: 112 Size: 16 [unused]
// float4 backlightColour; // Offset: 128 Size: 16 [unused]
// float4 specularScales; // Offset: 144 Size: 16 [unused]
// float3 specularDirection; // Offset: 160 Size: 12 [unused]
// float4 specularColourAndMultiplier;// Offset: 176 Size: 16 [unused]
// float4 fogColour; // Offset: 192 Size: 16 [unused]
// float4 fogParams; // Offset: 208 Size: 16 [unused]
// float4 hazeParams; // Offset: 224 Size: 16 [unused]
// float4 hazeParams2; // Offset: 240 Size: 16 [unused]
// float4 nightLightmapParam1; // Offset: 256 Size: 16 [unused]
// float4 nightLightmapParam2; // Offset: 272 Size: 16 [unused]
// float4 wetLightingParam; // Offset: 288 Size: 16 [unused]
// float4 snowEffectsParam; // Offset: 304 Size: 16 [unused]
// float4 ambientColour; // Offset: 320 Size: 16 [unused]
// float4 shadowBlend; // Offset: 336 Size: 16
// float4 maskParams; // Offset: 352 Size: 16
// float4 deferredSpecularParams; // Offset: 368 Size: 16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// TWaterRippleMap sampler NA NA 0 1
// TPreviousWaterRippleMap sampler NA NA 1 1
// TNormalMap sampler NA NA 2 1
// DepthMap sampler NA NA 3 1
// ReflectionMap sampler NA NA 4 1
// ReflectionMap2 sampler NA NA 5 1
// TMaskMap sampler NA NA 6 1
// TWaveFront sampler NA NA 7 1
// TShadowMask sampler NA NA 10 1
// DepthMap texture float4 2d 0 1
// TWaterRippleMap texture float4 2d 1 1
// TPreviousWaterRippleMap texture float4 2d 2 1
// TNormalMap texture float4 2d 3 1
// ReflectionMap texture float4 2d 4 1
// ReflectionMap2 texture float4 2d 5 1
// TShadowMask texture float4 2d 6 1
// TMaskMap texture float4 2d 7 1
// TWaveFront texture float4 2d 8 1
// $Globals cbuffer NA NA 0 1
// PerFrameConstantBuffer cbuffer NA NA 1 1
// RenderTargetConstantBuffer cbuffer NA NA 2 1
// CameraParamsConstantBuffer cbuffer NA NA 3 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float
// COLOR 1 xyzw 1 NONE float xyzw
// TEXCOORD 0 xyzw 2 NONE float
// TEXCOORD 1 xyzw 3 NONE float
// TEXCOORD 2 xyzw 4 NONE float w
// TEXCOORD 3 xyzw 5 NONE float xyzw
// TEXCOORD 4 xyzw 6 NONE float xy
// TEXCOORD 5 xyz 7 NONE float xyz
// TEXCOORD 6 xyzw 8 NONE float xy w
// TEXCOORD 7 xyzw 9 NONE float xyzw
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[53], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[20], immediateIndexed
dcl_constantbuffer cb1[23], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_sampler s7, mode_default
dcl_sampler s10, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_input_ps linear v1.xyzw
dcl_input_ps linear centroid v4.w
dcl_input_ps linear centroid v5.xyzw
dcl_input_ps linear centroid v6.xy
dcl_input_ps linear centroid v7.xyz
dcl_input_ps linear v8.xyw
dcl_input_ps linear centroid v9.xyzw
dcl_output o0.xyzw
dcl_temps 6
sample_indexable(texture2d)(float,float,float,float) r0.xy, v9.xyxx, t1.yzxw, s0
sample_indexable(texture2d)(float,float,float,float) r0.zw, v9.xyxx, t2.xwyz, s1
add r0.xy, -r0.zwzz, r0.xyxx
mad r0.xy, cb0[47].xxxx, r0.xyxx, r0.zwzz
add r0.xy, r0.xyxx, l(0.00196078443, 0.00196078443, 0.000000, 0.000000)
mad r0.xy, r0.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
div r1.xy, v8.xyxx, v8.wwww
add r1.z, -r1.y, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r0.z, r1.xzxx, t0.yzxw, s3
add r0.z, r0.z, cb0[37].z
div r0.z, cb0[37].w, r0.z
add r0.w, -r0.z, v9.z
add r0.z, r0.z, -v9.z
mul_sat r0.z, |r0.z|, cb0[49].w
add r1.y, r0.w, l(0.100000)
dp2 r0.w, r0.wwww, cb0[41].zzzz
lt r1.w, l(0.000000), r1.y
lt r1.y, r1.y, l(0.000000)
iadd r1.y, -r1.y, r1.w
itof r1.y, r1.y
mov_sat r1.y, r1.y
min r1.w, -r0.w, l(0.000000)
mov_sat r0.w, r0.w
max r0.w, r0.w, r1.y
exp r1.w, r1.w
add r1.w, -r1.w, l(1.000000)
max r1.y, r1.w, r1.y
mul r0.xy, r0.xyxx, r1.yyyy
mul r2.xy, r0.xyxx, cb0[42].xxxx
mul r0.xy, r0.xyxx, cb0[41].xxxx
max r0.xy, r0.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000)
min r0.xy, r0.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, cb0[41].yyyy
mul r3.xyzw, cb0[31].xxyy, cb0[48].wwww
div r3.xyzw, r2.xyxy, r3.xyzw
div r2.xy, r2.xyxx, cb0[31].zzzz
add r2.xy, r2.xyxx, v6.xyxx
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t3.xyzw, s2
mad r2.xyz, r2.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
add r3.xyzw, r3.xyzw, v5.xyzw
sample_indexable(texture2d)(float,float,float,float) r4.xyz, r3.zwzz, t3.xyzw, s2
sample_indexable(texture2d)(float,float,float,float) r3.xyz, r3.xyxx, t3.xyzw, s2
mad r3.xyz, r3.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mad r4.xyz, r4.xzyx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r4.xyz, r4.xyzx, cb0[32].yyyy
mad r3.xyz, cb0[32].xxxx, r3.xyzx, r4.xyzx
mad r2.xyz, cb0[32].zzzz, r2.xyzx, r3.xyzx
mad r2.xz, r0.xxyx, r2.yyyy, r2.xxzx
dp3 r0.x, r2.xyzx, r2.xyzx
rsq r0.x, r0.x
mul r2.xyz, r0.xxxx, r2.xyzx
mul r2.xyz, r2.xyzx, cb0[32].wwww
add r3.xyz, v7.xyzx, -cb3[14].xyzx
dp3 r0.x, r3.xyzx, r3.xyzx
sqrt r0.y, r0.x
mad_sat r0.x, r0.x, cb1[21].x, cb1[21].y
div r3.xyz, r3.xyzx, r0.yyyy
add r0.y, r0.y, -cb0[46].z
dp3 r1.w, r3.xyzx, r2.xyzx
add_sat r1.w, r1.w, l(1.000000)
add r3.xyz, cb0[39].xyzx, -cb0[40].xyzx
mad r3.xyz, r1.wwww, r3.xyzx, cb0[40].xyzx
add r4.xyz, -r3.xyzx, cb0[34].yzwy
mad r3.xyz, v4.wwww, r4.xyzx, r3.xyzx
mov_sat r2.y, cb1[22].w
add r2.w, -r2.y, l(1.000000)
mul r0.x, r0.x, r2.w
add r4.y, -v8.y, v8.w
mul r4.zw, cb2[0].zzzw, cb1[22].xxxx
mov r4.x, v8.x
mad r4.xy, v8.wwww, r4.zwzz, r4.xyxx
div r4.xy, r4.xyxx, v8.wwww
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r4.xyxx, t6.xyzw, s10
add r2.w, -r4.x, l(1.000000)
mad r2.w, r2.y, r2.w, r4.x
add r3.w, -r2.w, l(1.000000)
mad r0.x, r0.x, r3.w, r2.w
add r2.w, -r0.x, l(1.000000)
mad r0.x, r0.z, r2.w, r0.x
mad r4.xyz, cb1[22].wwww, r4.yzwy, -r0.xxxx
mad r4.xyz, r2.yyyy, r4.xyzx, r0.xxxx
mul r5.xyz, r3.xyzx, r4.xyzx
mad r3.xyz, -r3.xyzx, r4.xyzx, cb0[36].zzzz
add r4.xyzw, v7.xzxz, cb0[33].xyzw
mul r4.xyzw, r4.xyzw, cb0[46].xxxx
mul r4.xyzw, r4.xyzw, cb0[48].wwww
mul r4.xyzw, r4.xyzw, l(0.050000, 0.050000, 0.050000, 0.050000)
sample_indexable(texture2d)(float,float,float,float) r0.x, r4.xyxx, t7.xyzw, s6
sample_indexable(texture2d)(float,float,float,float) r0.z, r4.zwzz, t7.xyzw, s6
add r0.x, r0.z, r0.x
add r4.xyzw, v7.xzxz, cb0[35].xyzw
mul r4.xyzw, r4.xyzw, cb0[36].xxyy
mul r4.xyzw, r4.xyzw, l(0.050000, 0.050000, 0.050000, 0.050000)
sample_indexable(texture2d)(float,float,float,float) r2.yw, r4.xyxx, t8.xywz, s7
sample_indexable(texture2d)(float,float,float,float) r4.xy, r4.zwzz, t8.yzxw, s7
add r0.z, r2.w, r4.y
mul r2.y, r2.y, r4.x
mul r0.z, r0.z, v4.w
mul r0.z, r0.z, r0.x
mul r2.w, r0.z, r2.y
mad r0.z, -r2.y, r0.z, l(1.000000)
mad r3.xyz, r2.wwww, r3.xyzx, r5.xyzx
mul r2.y, l(0.300000), cb0[52].z
mad r2.w, cb0[52].w, l(0.300000), -r2.y
mad r2.y, r1.w, r2.w, r2.y
log r1.w, r1.w
mul r1.w, r1.w, cb0[38].z
exp r1.w, r1.w
mad_sat r1.xz, r2.xxzx, r2.yyyy, r1.xxzx
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xzxx, t4.xyzw, s4
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r1.xzxx, t5.xyzw, s5
movc r2.xyzw, cb3[19].xxxx, r2.xyzw, r4.xyzw
mul r4.xyz, r2.xyzx, cb1[0].yyyy
mad r2.xyz, r2.xyzx, cb1[0].wwww, l(1.000000, 1.000000, 1.000000, 0.000000)
div r2.xyz, r4.xyzx, r2.xyzx
add r2.xyz, -r3.xyzx, r2.xyzx
add r1.x, -cb0[38].x, cb0[38].y
mad r1.x, r1.w, r1.x, cb0[38].x
mul r1.x, r2.w, r1.x
mul r1.x, r0.z, r1.x
mad r1.xzw, r1.xxxx, r2.xxyz, r3.xxyz
add r2.x, -cb0[46].z, cb0[46].w
div_sat r0.y, r0.y, r2.x
add r0.y, -r0.y, l(1.000000)
mul r0.y, r0.y, cb0[45].x
mul r0.x, r0.x, r0.y
mul r2.xy, v7.zxzz, cb0[45].yyyy
mul r2.xy, r2.xyxx, l(0.050000, 0.050000, 0.000000, 0.000000)
mul r2.zw, cb0[34].xxxx, cb0[49].xxxy
mad r3.xy, r2.zwzz, cb0[30].wwww, r2.yxyy
mad r2.xy, r2.zwzz, cb0[31].wwww, r2.xyxx
sample_indexable(texture2d)(float,float,float,float) r0.y, r2.xyxx, t7.xyzw, s6
sample_indexable(texture2d)(float,float,float,float) r2.x, r3.xyxx, t7.yxzw, s6
mul r0.x, r0.x, r2.x
mul r0.x, r0.y, r0.x
mad r0.xyz, r0.xxxx, r0.zzzz, r1.xzwx
mad r0.xyz, r0.xyzx, v1.wwww, v1.xyzx
mul r1.xzw, r0.xxyz, cb1[0].zzzz
mad r0.xyz, r0.xyzx, cb1[0].xxxx, l(1.000000, 1.000000, 1.000000, 0.000000)
div o0.xyz, r1.xzwx, r0.xyzx
mov_sat r0.x, v9.w
min r0.x, r1.y, r0.x
mul o0.w, r0.w, r0.x
ret
// Approximately 144 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/03/2015 05:04 PM   
Yep, I think you are looking at the right general area - booleans and integers are problem areas for the decompiler due to fundamental differences between typeless GPU registers and fully typed HLSL variables. I think you actually need to change it from this: [code] r1.w = 0 < r1.y; r1.y = r1.y < 0; r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0); [/code] To this: [code] r1.w = (0 < r1.y ? -1 : 0); r1.y = (r1.y < 0 ? -1 : 0); r1.y = (int)r1.w - (int)r1.y; [/code] The problem here is that in HLSL the result of a boolean test is 0 or 1, but in shader assembly it's 0 or 0xffffffff (-1 as a signed integer). 3DMigoto is taking a different approach and trying to keep track of which components of which variables are booleans (which is why the iadd looked funny), but I don't think it gets it right in every situation.
Yep, I think you are looking at the right general area - booleans and integers are problem areas for the decompiler due to fundamental differences between typeless GPU registers and fully typed HLSL variables.

I think you actually need to change it from this:

r1.w = 0 < r1.y;
r1.y = r1.y < 0;
r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0);


To this:

r1.w = (0 < r1.y ? -1 : 0);
r1.y = (r1.y < 0 ? -1 : 0);
r1.y = (int)r1.w - (int)r1.y;


The problem here is that in HLSL the result of a boolean test is 0 or 1, but in shader assembly it's 0 or 0xffffffff (-1 as a signed integer). 3DMigoto is taking a different approach and trying to keep track of which components of which variables are booleans (which is why the iadd looked funny), but I don't think it gets it right in every situation.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

Posted 12/04/2015 03:22 AM   
Dang, that diff I posted only has 5 lines that don't line up, and those are three. :-> When I paste in DarkStarSword's code into the shader, I get the same iadd instruction desired, so this is very likely the fix. I actually have prototyped a generalized fix for this -1 vs. 1 problem, but haven't yet tested it enough to have confidence in it. I'll use your shader here as another example.
Dang, that diff I posted only has 5 lines that don't line up, and those are three. :->

When I paste in DarkStarSword's code into the shader, I get the same iadd instruction desired, so this is very likely the fix.


I actually have prototyped a generalized fix for this -1 vs. 1 problem, but haven't yet tested it enough to have confidence in it. I'll use your shader here as another example.

Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers

Posted 12/04/2015 11:05 AM   
Glad to hear I wasn't hallucinating :)
Glad to hear I wasn't hallucinating :)

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/04/2015 11:54 AM   
Is it yet possible to share the variables beteen shaders from main() for example v1? I searched the wiki page but I coudn't find anything in that matter.
Is it yet possible to share the variables beteen shaders from main() for example v1? I searched the wiki page but I coudn't find anything in that matter.

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/06/2015 02:56 PM   
What type of shader are you trying to copy them from? For vertex shaders these variables come from the vertex buffers, and starting with 3DMigoto 1.2.11 it is possible to copy a vertex buffer into a texture slot and 3DMigoto will convert it into a structured buffer making it possible to index to look up the inputs to any of the vertices in the draw call. Alternatively, you can copy it into a constant buffer slot, but doing so will make it a lot harder to look up individual entries as you cannot simply index them like you can with a structured buffer (I have got this to work, but there's a whole bunch of gotchas involved). Please note that there might be an issue with this feature if the game is passing a vertex offset of a per-draw call basis (3DMigoto takes care of the offset the game sets when binding the vertex buffer, but not the individual draw calls - I need to find a game that does that to test it). I'm using this in FC4 to look up the position of other vertices (I'm not copying it between shaders, but that should work). [code] [ShaderOverrideCrosshairMapAndIcons] Hash = 50344260ea3c9a9c vs-t100 = vb0 [/code] [code] // Structure of the vertex buffer - this essentially matches the input // signature of the shader, but the formats won't be interpreted the same since // that relies on the input assembler layout. In this case that means we can't // use a float4 for the color0 entry, as that would mean 4x4 byte values, but // in the vertex buffer it's only 4x1 byte values. Since we don't actually care // about it, just use a float so that the size matches. struct vb_entry { float2 vb_position; float2 vb_texcoord; // Don't be fooled by the float4 in the input signature - in // the vertex buffer this is just a single 4 byte value: float color0; }; StructuredBuffer<struct vb_entry> vb_struct : register(t100); float2 find_quad_center(uint id) { // Round down to the first vertex in this icon. Each icon is made up of // two triangles for six vertices each: id = id / 6 * 6; // Look up two diagonally oposite vertices so that the average is at // the center. In this game I can get away with vertex 0 and 2 - other // games may need different vertices. If all else fails, we could // always average all six to find the center float2 pos1 = vb_struct[id].vb_position; float2 pos2 = vb_struct[id + 2].vb_position; return (pos1 + pos2) / 2; } [/code] For reference, the input signature of that shader is (I added the SV_VertexID, which is what I pass to find_quad_center): [code] void main( float2 v0 : position0, float2 v1 : texcoord0, float4 v2 : color0, out float4 o0 : SV_Position0, out float4 o1 : TEXCOORD0, out float4 o2 : TEXCOORD1, uint id : SV_VertexID ) [/code] The real trick here is going to be creating a structure definition that matches the layout in the vertex buffer since there is currently no way to dump out the Input Assembler Layout which would tell you the binary encoding of each field. You might be able to guess - in the above example there wasn't anything too surprising, as the position and texcoord were declared as float2s in the signature and were in fact 2 x 32bit floats in the vertex buffer, but the color was declared as a float4, but was actually only a single 4 byte value. You can use frame analysis to dump out the vertex buffer as text (analyse_options=dump_vb_txt), which will tell you the structure size ("stride") will try to decode everything in the buffer as 32bit floats (at some point I want to make it use the Input Assembler layout to use the correct format to decode them properly, but DX is missing the APIs to make that easy). dump_cb_txt will dump from the offset to the end of the buffer, which will probably include a whole bunch of unrelated data - so don't pay too much attention to it beyond the first couple of entries, especially if the pattern seems to change. For other shader types, the variables are passed from earlier shaders and cannot be copied directly. It would be tricky to copy these, but you coule potentially copy the inputs from the previous shader instead and recalculate them in the destination shader, or perhaps add an extra render target output to the pixel shader and write them there.
What type of shader are you trying to copy them from?

For vertex shaders these variables come from the vertex buffers, and starting with 3DMigoto 1.2.11 it is possible to copy a vertex buffer into a texture slot and 3DMigoto will convert it into a structured buffer making it possible to index to look up the inputs to any of the vertices in the draw call. Alternatively, you can copy it into a constant buffer slot, but doing so will make it a lot harder to look up individual entries as you cannot simply index them like you can with a structured buffer (I have got this to work, but there's a whole bunch of gotchas involved).

Please note that there might be an issue with this feature if the game is passing a vertex offset of a per-draw call basis (3DMigoto takes care of the offset the game sets when binding the vertex buffer, but not the individual draw calls - I need to find a game that does that to test it).

I'm using this in FC4 to look up the position of other vertices (I'm not copying it between shaders, but that should work).

[ShaderOverrideCrosshairMapAndIcons]
Hash = 50344260ea3c9a9c
vs-t100 = vb0


// Structure of the vertex buffer - this essentially matches the input
// signature of the shader, but the formats won't be interpreted the same since
// that relies on the input assembler layout. In this case that means we can't
// use a float4 for the color0 entry, as that would mean 4x4 byte values, but
// in the vertex buffer it's only 4x1 byte values. Since we don't actually care
// about it, just use a float so that the size matches.
struct vb_entry
{
float2 vb_position;
float2 vb_texcoord;
// Don't be fooled by the float4 in the input signature - in
// the vertex buffer this is just a single 4 byte value:
float color0;
};

StructuredBuffer<struct vb_entry> vb_struct : register(t100);

float2 find_quad_center(uint id)
{
// Round down to the first vertex in this icon. Each icon is made up of
// two triangles for six vertices each:
id = id / 6 * 6;

// Look up two diagonally oposite vertices so that the average is at
// the center. In this game I can get away with vertex 0 and 2 - other
// games may need different vertices. If all else fails, we could
// always average all six to find the center
float2 pos1 = vb_struct[id].vb_position;
float2 pos2 = vb_struct[id + 2].vb_position;

return (pos1 + pos2) / 2;
}


For reference, the input signature of that shader is (I added the SV_VertexID, which is what I pass to find_quad_center):
void main(
float2 v0 : position0,
float2 v1 : texcoord0,
float4 v2 : color0,
out float4 o0 : SV_Position0,
out float4 o1 : TEXCOORD0,
out float4 o2 : TEXCOORD1,

uint id : SV_VertexID

)

The real trick here is going to be creating a structure definition that matches the layout in the vertex buffer since there is currently no way to dump out the Input Assembler Layout which would tell you the binary encoding of each field. You might be able to guess - in the above example there wasn't anything too surprising, as the position and texcoord were declared as float2s in the signature and were in fact 2 x 32bit floats in the vertex buffer, but the color was declared as a float4, but was actually only a single 4 byte value.

You can use frame analysis to dump out the vertex buffer as text (analyse_options=dump_vb_txt), which will tell you the structure size ("stride") will try to decode everything in the buffer as 32bit floats (at some point I want to make it use the Input Assembler layout to use the correct format to decode them properly, but DX is missing the APIs to make that easy). dump_cb_txt will dump from the offset to the end of the buffer, which will probably include a whole bunch of unrelated data - so don't pay too much attention to it beyond the first couple of entries, especially if the pattern seems to change.


For other shader types, the variables are passed from earlier shaders and cannot be copied directly. It would be tricky to copy these, but you coule potentially copy the inputs from the previous shader instead and recalculate them in the destination shader, or perhaps add an extra render target output to the pixel shader and write them there.

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

Posted 12/06/2015 04:53 PM   
I wish to copy TEXCOORD3 from the shader below: [code]// lake bottom cbuffer _Globals : register(b0) { float2 AmbientLightMapScale : packoffset(c0); float4 TColourMapChannelScale : packoffset(c1); float4 TColourMapChannelMin : packoffset(c2); float2 ColourMapScale : packoffset(c3); float4 Map1UVScaleAndOffset : packoffset(c4); float4 Map2UVScaleAndOffset : packoffset(c5); float4 Map3UVScaleAndOffset : packoffset(c6); float4 Map4UVScaleAndOffset : packoffset(c7); float4 TrackFresnelParameters : packoffset(c8); float4 TrackSpecularParameters : packoffset(c9); float DetailBlendScale : packoffset(c10); float BlendMaskSoftness : packoffset(c10.y); float2 BlendMaskUVScale : packoffset(c10.z); float InfieldBlendMinPoint : packoffset(c11); float InfieldBlendMaxPoint : packoffset(c11.y); float EdgeSCurveSteepness : packoffset(c11.z); float EdgeSCurveShift : packoffset(c11.w); float EdgeBlendMaskUScale : packoffset(c12); float EdgeBlendMaskVScale : packoffset(c12.y); float terrainXFade : packoffset(c12.z); } cbuffer RenderTargetConstantBuffer : register(b2) { float4 viewportDimensions : packoffset(c0); } cbuffer CameraParamsConstantBuffer : register(b3) { float4x4 projection : packoffset(c0); float4x4 viewProjection : packoffset(c4); row_major float3x4 view : packoffset(c8); row_major float3x4 viewI : packoffset(c11); float3 eyePositionWS : packoffset(c14); float4x4 inverseProj : packoffset(c15); bool leftEye : packoffset(c19); bool padding3[3] : packoffset(c20); } cbuffer PerFrameConstantBuffer : register(b1) { float4 colorBufferEncodingParams : packoffset(c0); float4 envMapEncodingParams : packoffset(c1); float4 velocityEncodingParams : packoffset(c2); float4 snowEffectsParam2 : packoffset(c3); float4 sunDirectionAndTime : packoffset(c4); float4 sunColour : packoffset(c5); float4 skylightColour : packoffset(c6); float4 ambientOcclusionScales : packoffset(c7); float4 backlightColour : packoffset(c8); float4 specularScales : packoffset(c9); float3 specularDirection : packoffset(c10); float4 specularColourAndMultiplier : packoffset(c11); float4 fogColour : packoffset(c12); float4 fogParams : packoffset(c13); float4 hazeParams : packoffset(c14); float4 hazeParams2 : packoffset(c15); float4 nightLightmapParam1 : packoffset(c16); float4 nightLightmapParam2 : packoffset(c17); float4 wetLightingParam : packoffset(c18); float4 snowEffectsParam : packoffset(c19); float4 ambientColour : packoffset(c20); float4 shadowBlend : packoffset(c21); float4 maskParams : packoffset(c22); float4 deferredSpecularParams : packoffset(c23); } SamplerState TSkyLightMapWS_s : register(s0); SamplerState TDynamicAmbientOcclusionMask_s : register(s1); SamplerState TDiffuseSpecMap2_s : register(s2); SamplerState TDiffuseSpecMap3_s : register(s3); SamplerState TBlendMap2_s : register(s4); SamplerState TAmbientOcclusion_s : register(s5); SamplerState TColourMap_s : register(s6); SamplerState TShadowMask_s : register(s10); Texture2D<float4> TDiffuseSpecMap2 : register(t0); Texture2D<float4> TDiffuseSpecMap3 : register(t1); Texture2D<float4> TBlendMap2 : register(t2); Texture2D<float4> TColourMap : register(t3); Texture2D<float4> TAmbientOcclusion : register(t4); Texture2D<float4> TDynamicAmbientOcclusionMask : register(t5); Texture2D<float4> TShadowMask : register(t6); Texture2D<float4> TSkyLightMapWS : register(t7); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( float4 v0 : SV_Position0, linear centroid float4 v1 : TEXCOORD0, linear centroid float4 v2 : TEXCOORD1, float4 v3 : TEXCOORD2, linear centroid float4 v4 : TEXCOORD3, linear centroid float4 v5 : TEXCOORD4, linear centroid float4 v6 : TEXCOORD5, linear centroid float4 v7 : COLOR0, linear centroid float4 v8 : COLOR1, out float4 o0 : SV_Target0) { float4 r0,r1,r2,r3,r4,r5,r6; uint4 bitmask, uiDest; float4 fDest; r0.x = 1 + -v4.z; r0.x = 1 + -r0.x; r0.yz = float2(1,1) / Map2UVScaleAndOffset.xy; r0.z = r0.x * r0.z + Map2UVScaleAndOffset.w; r1.x = v4.x * r0.y + Map2UVScaleAndOffset.z; r1.y = 1 + -r0.z; r0.y = 1 + -r1.y; r2.xyzw = TDiffuseSpecMap2.Sample(TDiffuseSpecMap2_s, r1.xy).xyzw; r1.x = BlendMaskUVScale.x * r1.x; r1.z = -r0.y * BlendMaskUVScale.y + 1; r0.y = TBlendMap2.Sample(TBlendMap2_s, r1.xz).y; r0.z = 1 + BlendMaskSoftness; r0.w = 0.5 * BlendMaskSoftness; r0.y = saturate(r0.y * r0.z + -r0.w); r0.y = saturate(v7.y * r0.y); r0.zw = float2(1,1) / Map3UVScaleAndOffset.xy; r0.x = r0.x * r0.w + Map3UVScaleAndOffset.w; r1.x = v4.x * r0.z + Map3UVScaleAndOffset.z; r1.y = 1 + -r0.x; r1.xyzw = TDiffuseSpecMap3.Sample(TDiffuseSpecMap3_s, r1.xy).xyzw; r1.xyzw = r1.xyzw + -r2.xyzw; r0.xyzw = r0.yyyy * r1.xyzw + r2.xyzw; r1.x = v5.w; r1.y = v6.w; r2.xyz = TColourMap.Sample(TColourMap_s, r1.xy).xyz; r1.xyz = TAmbientOcclusion.Sample(TAmbientOcclusion_s, r1.xy).xzw; r2.xyz = r2.xyz * TColourMapChannelScale.xyz + TColourMapChannelMin.xyz; r2.xyz = ColourMapScale.xxx * r2.xyz; r0.xyz = r2.xyz * r0.xyz; r2.xyz = -eyePositionWS.xyz + v4.xyz; r1.w = dot(r2.xyz, r2.xyz); r2.w = rsqrt(r1.w); r1.w = saturate(r1.w * shadowBlend.x + shadowBlend.y); r2.xyz = r2.xyz * r2.www; r2.w = dot(r2.xyz, v2.xyz); r3.x = r2.w + r2.w; r2.w = 1 + r2.w; r2.w = max(0, r2.w); r2.w = log2(r2.w); r2.w = TrackFresnelParameters.z * r2.w; r2.w = exp2(r2.w); r2.w = min(1, r2.w); r2.xyz = v2.xyz * -r3.xxx + r2.xyz; r2.x = saturate(dot(r2.xyz, specularDirection.xyz)); r2.x = max(9.99999975e-006, r2.x); r2.x = log2(r2.x); r2.x = TrackSpecularParameters.y * r2.x; r2.x = exp2(r2.x); r0.w = r2.x * r0.w; r2.x = TrackFresnelParameters.y + -TrackFresnelParameters.x; r2.x = r2.w * r2.x + TrackFresnelParameters.x; r2.x = TrackSpecularParameters.x * r2.x; r1.xy = float2(-1,-1) + r1.xy; r2.yz = ambientOcclusionScales.xx * r1.xy + float2(1,1); r1.x = ambientOcclusionScales.x * r1.x; r1.x = r1.x * 0.5 + 1; r1.y = r2.x * r2.z; r0.w = r1.y * r0.w; r1.y = saturate(maskParams.w); r2.x = 1 + -r1.y; r1.w = r2.x * r1.w; r2.xw = maskParams.xx * viewportDimensions.zw; r3.y = v1.w + -v1.y; r3.x = v1.x; r2.xw = v1.ww * r2.xw + r3.xy; r3.xy = r3.xy / v1.ww; r3.x = TDynamicAmbientOcclusionMask.Sample(TDynamicAmbientOcclusionMask_s, r3.xy).x; r2.xw = r2.xw / v1.ww; r4.xyzw = TShadowMask.Sample(TShadowMask_s, r2.xw).xyzw; r2.x = 1 + -r4.x; r1.y = r1.y * r2.x + r4.x; r1.z = r1.z + -r1.y; r1.y = r1.w * r1.z + r1.y; r0.w = r1.y * r0.w; r3.yzw = specularColourAndMultiplier.xyz * r0.www; r2.xzw = ambientColour.xyz * r2.zzz; r1.zw = v4.xz * AmbientLightMapScale.xy + float2(0.5,0.5); r5.xyz = TSkyLightMapWS.Sample(TSkyLightMapWS_s, r1.zw).xyz; r2.xyz = r5.xyz * r2.yyy + r2.xzw; r5.xyz = maskParams.www * r4.yzw; r4.xyz = r4.yzw * float3(2,2,2) + float3(-1,-1,-1); r0.w = saturate(dot(v2.xyz, sunDirectionAndTime.xyz)); r6.xyz = sunColour.xyz * r0.www; r5.xyz = r6.xyz * r1.yyy + r5.xyz; r0.w = r1.y * 0.5 + 0.5; r1.xyz = r5.xyz * r1.xxx + r2.xyz; r1.w = maskParams.w == 0.000000; r2.xyz = r1.www ? r4.xyz : 0; r1.xyz = r2.xyz * r0.www + r1.xyz; r1.xyz = max(float3(0,0,0), r1.xyz); r0.xyz = r0.xyz * r1.xyz + r3.yzw; r0.xyz = r0.xyz * r3.xxx; r0.xyz = r0.xyz * v8.www + v8.xyz; r1.xyz = colorBufferEncodingParams.zzz * r0.xyz; r0.xyz = r0.xyz * colorBufferEncodingParams.xxx + float3(1,1,1); o0.xyz = r1.xyz / r0.xyz; o0.w = terrainXFade; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // using 3Dmigoto v1.2.13 on Sun Dec 06 14:40:22 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float2 AmbientLightMapScale; // Offset: 0 Size: 8 // float4 TColourMapChannelScale; // Offset: 16 Size: 16 // float4 TColourMapChannelMin; // Offset: 32 Size: 16 // float2 ColourMapScale; // Offset: 48 Size: 8 // float4 Map1UVScaleAndOffset; // Offset: 64 Size: 16 [unused] // float4 Map2UVScaleAndOffset; // Offset: 80 Size: 16 // float4 Map3UVScaleAndOffset; // Offset: 96 Size: 16 // float4 Map4UVScaleAndOffset; // Offset: 112 Size: 16 [unused] // float4 TrackFresnelParameters; // Offset: 128 Size: 16 // float4 TrackSpecularParameters; // Offset: 144 Size: 16 // float DetailBlendScale; // Offset: 160 Size: 4 [unused] // float BlendMaskSoftness; // Offset: 164 Size: 4 // float2 BlendMaskUVScale; // Offset: 168 Size: 8 // float InfieldBlendMinPoint; // Offset: 176 Size: 4 [unused] // float InfieldBlendMaxPoint; // Offset: 180 Size: 4 [unused] // float EdgeSCurveSteepness; // Offset: 184 Size: 4 [unused] // float EdgeSCurveShift; // Offset: 188 Size: 4 [unused] // float EdgeBlendMaskUScale; // Offset: 192 Size: 4 [unused] // float EdgeBlendMaskVScale; // Offset: 196 Size: 4 [unused] // float terrainXFade; // Offset: 200 Size: 4 // // } // // cbuffer RenderTargetConstantBuffer // { // // float4 viewportDimensions; // Offset: 0 Size: 16 // // } // // cbuffer CameraParamsConstantBuffer // { // // float4x4 projection; // Offset: 0 Size: 64 [unused] // float4x4 viewProjection; // Offset: 64 Size: 64 [unused] // row_major float3x4 view; // Offset: 128 Size: 48 [unused] // row_major float3x4 viewI; // Offset: 176 Size: 48 [unused] // float3 eyePositionWS; // Offset: 224 Size: 12 // float4x4 inverseProj; // Offset: 240 Size: 64 [unused] // bool leftEye; // Offset: 304 Size: 4 [unused] // bool padding3[3]; // Offset: 320 Size: 36 [unused] // // } // // cbuffer PerFrameConstantBuffer // { // // float4 colorBufferEncodingParams; // Offset: 0 Size: 16 // float4 envMapEncodingParams; // Offset: 16 Size: 16 [unused] // float4 velocityEncodingParams; // Offset: 32 Size: 16 [unused] // float4 snowEffectsParam2; // Offset: 48 Size: 16 [unused] // float4 sunDirectionAndTime; // Offset: 64 Size: 16 // float4 sunColour; // Offset: 80 Size: 16 // float4 skylightColour; // Offset: 96 Size: 16 [unused] // float4 ambientOcclusionScales; // Offset: 112 Size: 16 // float4 backlightColour; // Offset: 128 Size: 16 [unused] // float4 specularScales; // Offset: 144 Size: 16 [unused] // float3 specularDirection; // Offset: 160 Size: 12 // float4 specularColourAndMultiplier;// Offset: 176 Size: 16 // float4 fogColour; // Offset: 192 Size: 16 [unused] // float4 fogParams; // Offset: 208 Size: 16 [unused] // float4 hazeParams; // Offset: 224 Size: 16 [unused] // float4 hazeParams2; // Offset: 240 Size: 16 [unused] // float4 nightLightmapParam1; // Offset: 256 Size: 16 [unused] // float4 nightLightmapParam2; // Offset: 272 Size: 16 [unused] // float4 wetLightingParam; // Offset: 288 Size: 16 [unused] // float4 snowEffectsParam; // Offset: 304 Size: 16 [unused] // float4 ambientColour; // Offset: 320 Size: 16 // float4 shadowBlend; // Offset: 336 Size: 16 // float4 maskParams; // Offset: 352 Size: 16 // float4 deferredSpecularParams; // Offset: 368 Size: 16 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // TSkyLightMapWS sampler NA NA 0 1 // TDynamicAmbientOcclusionMask sampler NA NA 1 1 // TDiffuseSpecMap2 sampler NA NA 2 1 // TDiffuseSpecMap3 sampler NA NA 3 1 // TBlendMap2 sampler NA NA 4 1 // TAmbientOcclusion sampler NA NA 5 1 // TColourMap sampler NA NA 6 1 // TShadowMask sampler NA NA 10 1 // TDiffuseSpecMap2 texture float4 2d 0 1 // TDiffuseSpecMap3 texture float4 2d 1 1 // TBlendMap2 texture float4 2d 2 1 // TColourMap texture float4 2d 3 1 // TAmbientOcclusion texture float4 2d 4 1 // TDynamicAmbientOcclusionMask texture float4 2d 5 1 // TShadowMask texture float4 2d 6 1 // TSkyLightMapWS texture float4 2d 7 1 // $Globals cbuffer NA NA 0 1 // PerFrameConstantBuffer cbuffer NA NA 1 1 // RenderTargetConstantBuffer cbuffer NA NA 2 1 // CameraParamsConstantBuffer cbuffer NA NA 3 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float // TEXCOORD 0 xyzw 1 NONE float xy w // TEXCOORD 1 xyz 2 NONE float xyz // TEXCOORD 2 xyzw 3 NONE float // TEXCOORD 3 xyzw 4 NONE float xyz // TEXCOORD 4 xyzw 5 NONE float w // TEXCOORD 5 xyzw 6 NONE float w // COLOR 0 xyzw 7 NONE float y // COLOR 1 xyzw 8 NONE float xyzw // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // ps_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[13], immediateIndexed dcl_constantbuffer cb2[1], immediateIndexed dcl_constantbuffer cb3[15], immediateIndexed dcl_constantbuffer cb1[23], immediateIndexed dcl_sampler s0, mode_default dcl_sampler s1, mode_default dcl_sampler s2, mode_default dcl_sampler s3, mode_default dcl_sampler s4, mode_default dcl_sampler s5, mode_default dcl_sampler s6, mode_default dcl_sampler s10, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_resource_texture2d (float,float,float,float) t1 dcl_resource_texture2d (float,float,float,float) t2 dcl_resource_texture2d (float,float,float,float) t3 dcl_resource_texture2d (float,float,float,float) t4 dcl_resource_texture2d (float,float,float,float) t5 dcl_resource_texture2d (float,float,float,float) t6 dcl_resource_texture2d (float,float,float,float) t7 dcl_input_ps linear centroid v1.xyw dcl_input_ps linear centroid v2.xyz dcl_input_ps linear centroid v4.xyz dcl_input_ps linear centroid v5.w dcl_input_ps linear centroid v6.w dcl_input_ps linear centroid v7.y dcl_input_ps linear centroid v8.xyzw dcl_output o0.xyzw dcl_temps 7 add r0.x, -v4.z, l(1.000000) add r0.x, -r0.x, l(1.000000) div r0.yz, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[5].xxyx mad r0.z, r0.x, r0.z, cb0[5].w mad r1.x, v4.x, r0.y, cb0[5].z add r1.y, -r0.z, l(1.000000) add r0.y, -r1.y, l(1.000000) sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xyxx, t0.xyzw, s2 mul r1.x, r1.x, cb0[10].z mad r1.z, -r0.y, cb0[10].w, l(1.000000) sample_indexable(texture2d)(float,float,float,float) r0.y, r1.xzxx, t2.xyzw, s4 add r0.z, cb0[10].y, l(1.000000) mul r0.w, cb0[10].y, l(0.500000) mad_sat r0.y, r0.y, r0.z, -r0.w mul_sat r0.y, r0.y, v7.y div r0.zw, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[6].xxxy mad r0.x, r0.x, r0.w, cb0[6].w mad r1.x, v4.x, r0.z, cb0[6].z add r1.y, -r0.x, l(1.000000) sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t1.xyzw, s3 add r1.xyzw, -r2.xyzw, r1.xyzw mad r0.xyzw, r0.yyyy, r1.xyzw, r2.xyzw mov r1.x, v5.w mov r1.y, v6.w sample_indexable(texture2d)(float,float,float,float) r2.xyz, r1.xyxx, t3.xyzw, s6 sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t4.xzwy, s5 mad r2.xyz, r2.xyzx, cb0[1].xyzx, cb0[2].xyzx mul r2.xyz, r2.xyzx, cb0[3].xxxx mul r0.xyz, r0.xyzx, r2.xyzx add r2.xyz, v4.xyzx, -cb3[14].xyzx dp3 r1.w, r2.xyzx, r2.xyzx rsq r2.w, r1.w mad_sat r1.w, r1.w, cb1[21].x, cb1[21].y mul r2.xyz, r2.wwww, r2.xyzx dp3 r2.w, r2.xyzx, v2.xyzx add r3.x, r2.w, r2.w add r2.w, r2.w, l(1.000000) max r2.w, r2.w, l(0.000000) log r2.w, r2.w mul r2.w, r2.w, cb0[8].z exp r2.w, r2.w min r2.w, r2.w, l(1.000000) mad r2.xyz, v2.xyzx, -r3.xxxx, r2.xyzx dp3_sat r2.x, r2.xyzx, cb1[10].xyzx max r2.x, r2.x, l(0.000010) log r2.x, r2.x mul r2.x, r2.x, cb0[9].y exp r2.x, r2.x mul r0.w, r0.w, r2.x add r2.x, -cb0[8].x, cb0[8].y mad r2.x, r2.w, r2.x, cb0[8].x mul r2.x, r2.x, cb0[9].x add r1.xy, r1.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000) mad r2.yz, cb1[7].xxxx, r1.xxyx, l(0.000000, 1.000000, 1.000000, 0.000000) mul r1.x, r1.x, cb1[7].x mad r1.x, r1.x, l(0.500000), l(1.000000) mul r1.y, r2.z, r2.x mul r0.w, r0.w, r1.y mov_sat r1.y, cb1[22].w add r2.x, -r1.y, l(1.000000) mul r1.w, r1.w, r2.x mul r2.xw, cb2[0].zzzw, cb1[22].xxxx add r3.y, -v1.y, v1.w mov r3.x, v1.x mad r2.xw, v1.wwww, r2.xxxw, r3.xxxy div r3.xy, r3.xyxx, v1.wwww sample_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t5.xyzw, s1 div r2.xw, r2.xxxw, v1.wwww sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.xwxx, t6.xyzw, s10 add r2.x, -r4.x, l(1.000000) mad r1.y, r1.y, r2.x, r4.x add r1.z, -r1.y, r1.z mad r1.y, r1.w, r1.z, r1.y mul r0.w, r0.w, r1.y mul r3.yzw, r0.wwww, cb1[11].xxyz mul r2.xzw, r2.zzzz, cb1[20].xxyz mad r1.zw, v4.xxxz, cb0[0].xxxy, l(0.000000, 0.000000, 0.500000, 0.500000) sample_indexable(texture2d)(float,float,float,float) r5.xyz, r1.zwzz, t7.xyzw, s0 mad r2.xyz, r5.xyzx, r2.yyyy, r2.xzwx mul r5.xyz, r4.yzwy, cb1[22].wwww mad r4.xyz, r4.yzwy, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000) dp3_sat r0.w, v2.xyzx, cb1[4].xyzx mul r6.xyz, r0.wwww, cb1[5].xyzx mad r5.xyz, r6.xyzx, r1.yyyy, r5.xyzx mad r0.w, r1.y, l(0.500000), l(0.500000) mad r1.xyz, r5.xyzx, r1.xxxx, r2.xyzx eq r1.w, cb1[22].w, l(0.000000) and r2.xyz, r4.xyzx, r1.wwww mad r1.xyz, r2.xyzx, r0.wwww, r1.xyzx max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) mad r0.xyz, r0.xyzx, r1.xyzx, r3.yzwy mul r0.xyz, r3.xxxx, r0.xyzx mad r0.xyz, r0.xyzx, v8.wwww, v8.xyzx mul r1.xyz, r0.xyzx, cb1[0].zzzz mad r0.xyz, r0.xyzx, cb1[0].xxxx, l(1.000000, 1.000000, 1.000000, 0.000000) div o0.xyz, r1.xyzx, r0.xyzx mov o0.w, cb0[12].z ret // Approximately 98 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ [/code]
I wish to copy TEXCOORD3 from the shader below:

// lake bottom

cbuffer _Globals : register(b0)
{
float2 AmbientLightMapScale : packoffset(c0);
float4 TColourMapChannelScale : packoffset(c1);
float4 TColourMapChannelMin : packoffset(c2);
float2 ColourMapScale : packoffset(c3);
float4 Map1UVScaleAndOffset : packoffset(c4);
float4 Map2UVScaleAndOffset : packoffset(c5);
float4 Map3UVScaleAndOffset : packoffset(c6);
float4 Map4UVScaleAndOffset : packoffset(c7);
float4 TrackFresnelParameters : packoffset(c8);
float4 TrackSpecularParameters : packoffset(c9);
float DetailBlendScale : packoffset(c10);
float BlendMaskSoftness : packoffset(c10.y);
float2 BlendMaskUVScale : packoffset(c10.z);
float InfieldBlendMinPoint : packoffset(c11);
float InfieldBlendMaxPoint : packoffset(c11.y);
float EdgeSCurveSteepness : packoffset(c11.z);
float EdgeSCurveShift : packoffset(c11.w);
float EdgeBlendMaskUScale : packoffset(c12);
float EdgeBlendMaskVScale : packoffset(c12.y);
float terrainXFade : packoffset(c12.z);
}

cbuffer RenderTargetConstantBuffer : register(b2)
{
float4 viewportDimensions : packoffset(c0);
}

cbuffer CameraParamsConstantBuffer : register(b3)
{
float4x4 projection : packoffset(c0);
float4x4 viewProjection : packoffset(c4);
row_major float3x4 view : packoffset(c8);
row_major float3x4 viewI : packoffset(c11);
float3 eyePositionWS : packoffset(c14);
float4x4 inverseProj : packoffset(c15);
bool leftEye : packoffset(c19);
bool padding3[3] : packoffset(c20);
}

cbuffer PerFrameConstantBuffer : register(b1)
{
float4 colorBufferEncodingParams : packoffset(c0);
float4 envMapEncodingParams : packoffset(c1);
float4 velocityEncodingParams : packoffset(c2);
float4 snowEffectsParam2 : packoffset(c3);
float4 sunDirectionAndTime : packoffset(c4);
float4 sunColour : packoffset(c5);
float4 skylightColour : packoffset(c6);
float4 ambientOcclusionScales : packoffset(c7);
float4 backlightColour : packoffset(c8);
float4 specularScales : packoffset(c9);
float3 specularDirection : packoffset(c10);
float4 specularColourAndMultiplier : packoffset(c11);
float4 fogColour : packoffset(c12);
float4 fogParams : packoffset(c13);
float4 hazeParams : packoffset(c14);
float4 hazeParams2 : packoffset(c15);
float4 nightLightmapParam1 : packoffset(c16);
float4 nightLightmapParam2 : packoffset(c17);
float4 wetLightingParam : packoffset(c18);
float4 snowEffectsParam : packoffset(c19);
float4 ambientColour : packoffset(c20);
float4 shadowBlend : packoffset(c21);
float4 maskParams : packoffset(c22);
float4 deferredSpecularParams : packoffset(c23);
}
SamplerState TSkyLightMapWS_s : register(s0);
SamplerState TDynamicAmbientOcclusionMask_s : register(s1);
SamplerState TDiffuseSpecMap2_s : register(s2);
SamplerState TDiffuseSpecMap3_s : register(s3);
SamplerState TBlendMap2_s : register(s4);
SamplerState TAmbientOcclusion_s : register(s5);
SamplerState TColourMap_s : register(s6);
SamplerState TShadowMask_s : register(s10);
Texture2D<float4> TDiffuseSpecMap2 : register(t0);
Texture2D<float4> TDiffuseSpecMap3 : register(t1);
Texture2D<float4> TBlendMap2 : register(t2);
Texture2D<float4> TColourMap : register(t3);
Texture2D<float4> TAmbientOcclusion : register(t4);
Texture2D<float4> TDynamicAmbientOcclusionMask : register(t5);
Texture2D<float4> TShadowMask : register(t6);
Texture2D<float4> TSkyLightMapWS : register(t7);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
float4 v0 : SV_Position0,
linear centroid float4 v1 : TEXCOORD0,
linear centroid float4 v2 : TEXCOORD1,
float4 v3 : TEXCOORD2,
linear centroid float4 v4 : TEXCOORD3,
linear centroid float4 v5 : TEXCOORD4,
linear centroid float4 v6 : TEXCOORD5,
linear centroid float4 v7 : COLOR0,
linear centroid float4 v8 : COLOR1,
out float4 o0 : SV_Target0)
{
float4 r0,r1,r2,r3,r4,r5,r6;
uint4 bitmask, uiDest;
float4 fDest;

r0.x = 1 + -v4.z;
r0.x = 1 + -r0.x;
r0.yz = float2(1,1) / Map2UVScaleAndOffset.xy;
r0.z = r0.x * r0.z + Map2UVScaleAndOffset.w;
r1.x = v4.x * r0.y + Map2UVScaleAndOffset.z;
r1.y = 1 + -r0.z;
r0.y = 1 + -r1.y;
r2.xyzw = TDiffuseSpecMap2.Sample(TDiffuseSpecMap2_s, r1.xy).xyzw;
r1.x = BlendMaskUVScale.x * r1.x;
r1.z = -r0.y * BlendMaskUVScale.y + 1;
r0.y = TBlendMap2.Sample(TBlendMap2_s, r1.xz).y;
r0.z = 1 + BlendMaskSoftness;
r0.w = 0.5 * BlendMaskSoftness;
r0.y = saturate(r0.y * r0.z + -r0.w);
r0.y = saturate(v7.y * r0.y);
r0.zw = float2(1,1) / Map3UVScaleAndOffset.xy;
r0.x = r0.x * r0.w + Map3UVScaleAndOffset.w;
r1.x = v4.x * r0.z + Map3UVScaleAndOffset.z;
r1.y = 1 + -r0.x;
r1.xyzw = TDiffuseSpecMap3.Sample(TDiffuseSpecMap3_s, r1.xy).xyzw;
r1.xyzw = r1.xyzw + -r2.xyzw;
r0.xyzw = r0.yyyy * r1.xyzw + r2.xyzw;
r1.x = v5.w;
r1.y = v6.w;
r2.xyz = TColourMap.Sample(TColourMap_s, r1.xy).xyz;
r1.xyz = TAmbientOcclusion.Sample(TAmbientOcclusion_s, r1.xy).xzw;
r2.xyz = r2.xyz * TColourMapChannelScale.xyz + TColourMapChannelMin.xyz;
r2.xyz = ColourMapScale.xxx * r2.xyz;
r0.xyz = r2.xyz * r0.xyz;
r2.xyz = -eyePositionWS.xyz + v4.xyz;
r1.w = dot(r2.xyz, r2.xyz);
r2.w = rsqrt(r1.w);
r1.w = saturate(r1.w * shadowBlend.x + shadowBlend.y);
r2.xyz = r2.xyz * r2.www;
r2.w = dot(r2.xyz, v2.xyz);
r3.x = r2.w + r2.w;
r2.w = 1 + r2.w;
r2.w = max(0, r2.w);
r2.w = log2(r2.w);
r2.w = TrackFresnelParameters.z * r2.w;
r2.w = exp2(r2.w);
r2.w = min(1, r2.w);
r2.xyz = v2.xyz * -r3.xxx + r2.xyz;
r2.x = saturate(dot(r2.xyz, specularDirection.xyz));
r2.x = max(9.99999975e-006, r2.x);
r2.x = log2(r2.x);
r2.x = TrackSpecularParameters.y * r2.x;
r2.x = exp2(r2.x);
r0.w = r2.x * r0.w;
r2.x = TrackFresnelParameters.y + -TrackFresnelParameters.x;
r2.x = r2.w * r2.x + TrackFresnelParameters.x;
r2.x = TrackSpecularParameters.x * r2.x;
r1.xy = float2(-1,-1) + r1.xy;
r2.yz = ambientOcclusionScales.xx * r1.xy + float2(1,1);
r1.x = ambientOcclusionScales.x * r1.x;
r1.x = r1.x * 0.5 + 1;
r1.y = r2.x * r2.z;
r0.w = r1.y * r0.w;
r1.y = saturate(maskParams.w);
r2.x = 1 + -r1.y;
r1.w = r2.x * r1.w;
r2.xw = maskParams.xx * viewportDimensions.zw;
r3.y = v1.w + -v1.y;
r3.x = v1.x;
r2.xw = v1.ww * r2.xw + r3.xy;
r3.xy = r3.xy / v1.ww;
r3.x = TDynamicAmbientOcclusionMask.Sample(TDynamicAmbientOcclusionMask_s, r3.xy).x;
r2.xw = r2.xw / v1.ww;
r4.xyzw = TShadowMask.Sample(TShadowMask_s, r2.xw).xyzw;
r2.x = 1 + -r4.x;
r1.y = r1.y * r2.x + r4.x;
r1.z = r1.z + -r1.y;
r1.y = r1.w * r1.z + r1.y;
r0.w = r1.y * r0.w;
r3.yzw = specularColourAndMultiplier.xyz * r0.www;
r2.xzw = ambientColour.xyz * r2.zzz;
r1.zw = v4.xz * AmbientLightMapScale.xy + float2(0.5,0.5);
r5.xyz = TSkyLightMapWS.Sample(TSkyLightMapWS_s, r1.zw).xyz;
r2.xyz = r5.xyz * r2.yyy + r2.xzw;
r5.xyz = maskParams.www * r4.yzw;
r4.xyz = r4.yzw * float3(2,2,2) + float3(-1,-1,-1);
r0.w = saturate(dot(v2.xyz, sunDirectionAndTime.xyz));
r6.xyz = sunColour.xyz * r0.www;
r5.xyz = r6.xyz * r1.yyy + r5.xyz;
r0.w = r1.y * 0.5 + 0.5;
r1.xyz = r5.xyz * r1.xxx + r2.xyz;
r1.w = maskParams.w == 0.000000;
r2.xyz = r1.www ? r4.xyz : 0;
r1.xyz = r2.xyz * r0.www + r1.xyz;
r1.xyz = max(float3(0,0,0), r1.xyz);
r0.xyz = r0.xyz * r1.xyz + r3.yzw;
r0.xyz = r0.xyz * r3.xxx;
r0.xyz = r0.xyz * v8.www + v8.xyz;
r1.xyz = colorBufferEncodingParams.zzz * r0.xyz;
r0.xyz = r0.xyz * colorBufferEncodingParams.xxx + float3(1,1,1);
o0.xyz = r1.xyz / r0.xyz;
o0.w = terrainXFade;
return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// using 3Dmigoto v1.2.13 on Sun Dec 06 14:40:22 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float2 AmbientLightMapScale; // Offset: 0 Size: 8
// float4 TColourMapChannelScale; // Offset: 16 Size: 16
// float4 TColourMapChannelMin; // Offset: 32 Size: 16
// float2 ColourMapScale; // Offset: 48 Size: 8
// float4 Map1UVScaleAndOffset; // Offset: 64 Size: 16 [unused]
// float4 Map2UVScaleAndOffset; // Offset: 80 Size: 16
// float4 Map3UVScaleAndOffset; // Offset: 96 Size: 16
// float4 Map4UVScaleAndOffset; // Offset: 112 Size: 16 [unused]
// float4 TrackFresnelParameters; // Offset: 128 Size: 16
// float4 TrackSpecularParameters; // Offset: 144 Size: 16
// float DetailBlendScale; // Offset: 160 Size: 4 [unused]
// float BlendMaskSoftness; // Offset: 164 Size: 4
// float2 BlendMaskUVScale; // Offset: 168 Size: 8
// float InfieldBlendMinPoint; // Offset: 176 Size: 4 [unused]
// float InfieldBlendMaxPoint; // Offset: 180 Size: 4 [unused]
// float EdgeSCurveSteepness; // Offset: 184 Size: 4 [unused]
// float EdgeSCurveShift; // Offset: 188 Size: 4 [unused]
// float EdgeBlendMaskUScale; // Offset: 192 Size: 4 [unused]
// float EdgeBlendMaskVScale; // Offset: 196 Size: 4 [unused]
// float terrainXFade; // Offset: 200 Size: 4
//
// }
//
// cbuffer RenderTargetConstantBuffer
// {
//
// float4 viewportDimensions; // Offset: 0 Size: 16
//
// }
//
// cbuffer CameraParamsConstantBuffer
// {
//
// float4x4 projection; // Offset: 0 Size: 64 [unused]
// float4x4 viewProjection; // Offset: 64 Size: 64 [unused]
// row_major float3x4 view; // Offset: 128 Size: 48 [unused]
// row_major float3x4 viewI; // Offset: 176 Size: 48 [unused]
// float3 eyePositionWS; // Offset: 224 Size: 12
// float4x4 inverseProj; // Offset: 240 Size: 64 [unused]
// bool leftEye; // Offset: 304 Size: 4 [unused]
// bool padding3[3]; // Offset: 320 Size: 36 [unused]
//
// }
//
// cbuffer PerFrameConstantBuffer
// {
//
// float4 colorBufferEncodingParams; // Offset: 0 Size: 16
// float4 envMapEncodingParams; // Offset: 16 Size: 16 [unused]
// float4 velocityEncodingParams; // Offset: 32 Size: 16 [unused]
// float4 snowEffectsParam2; // Offset: 48 Size: 16 [unused]
// float4 sunDirectionAndTime; // Offset: 64 Size: 16
// float4 sunColour; // Offset: 80 Size: 16
// float4 skylightColour; // Offset: 96 Size: 16 [unused]
// float4 ambientOcclusionScales; // Offset: 112 Size: 16
// float4 backlightColour; // Offset: 128 Size: 16 [unused]
// float4 specularScales; // Offset: 144 Size: 16 [unused]
// float3 specularDirection; // Offset: 160 Size: 12
// float4 specularColourAndMultiplier;// Offset: 176 Size: 16
// float4 fogColour; // Offset: 192 Size: 16 [unused]
// float4 fogParams; // Offset: 208 Size: 16 [unused]
// float4 hazeParams; // Offset: 224 Size: 16 [unused]
// float4 hazeParams2; // Offset: 240 Size: 16 [unused]
// float4 nightLightmapParam1; // Offset: 256 Size: 16 [unused]
// float4 nightLightmapParam2; // Offset: 272 Size: 16 [unused]
// float4 wetLightingParam; // Offset: 288 Size: 16 [unused]
// float4 snowEffectsParam; // Offset: 304 Size: 16 [unused]
// float4 ambientColour; // Offset: 320 Size: 16
// float4 shadowBlend; // Offset: 336 Size: 16
// float4 maskParams; // Offset: 352 Size: 16
// float4 deferredSpecularParams; // Offset: 368 Size: 16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// TSkyLightMapWS sampler NA NA 0 1
// TDynamicAmbientOcclusionMask sampler NA NA 1 1
// TDiffuseSpecMap2 sampler NA NA 2 1
// TDiffuseSpecMap3 sampler NA NA 3 1
// TBlendMap2 sampler NA NA 4 1
// TAmbientOcclusion sampler NA NA 5 1
// TColourMap sampler NA NA 6 1
// TShadowMask sampler NA NA 10 1
// TDiffuseSpecMap2 texture float4 2d 0 1
// TDiffuseSpecMap3 texture float4 2d 1 1
// TBlendMap2 texture float4 2d 2 1
// TColourMap texture float4 2d 3 1
// TAmbientOcclusion texture float4 2d 4 1
// TDynamicAmbientOcclusionMask texture float4 2d 5 1
// TShadowMask texture float4 2d 6 1
// TSkyLightMapWS texture float4 2d 7 1
// $Globals cbuffer NA NA 0 1
// PerFrameConstantBuffer cbuffer NA NA 1 1
// RenderTargetConstantBuffer cbuffer NA NA 2 1
// CameraParamsConstantBuffer cbuffer NA NA 3 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy w
// TEXCOORD 1 xyz 2 NONE float xyz
// TEXCOORD 2 xyzw 3 NONE float
// TEXCOORD 3 xyzw 4 NONE float xyz
// TEXCOORD 4 xyzw 5 NONE float w
// TEXCOORD 5 xyzw 6 NONE float w
// COLOR 0 xyzw 7 NONE float y
// COLOR 1 xyzw 8 NONE float xyzw
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[13], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[15], immediateIndexed
dcl_constantbuffer cb1[23], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_sampler s4, mode_default
dcl_sampler s5, mode_default
dcl_sampler s6, mode_default
dcl_sampler s10, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texture2d (float,float,float,float) t7
dcl_input_ps linear centroid v1.xyw
dcl_input_ps linear centroid v2.xyz
dcl_input_ps linear centroid v4.xyz
dcl_input_ps linear centroid v5.w
dcl_input_ps linear centroid v6.w
dcl_input_ps linear centroid v7.y
dcl_input_ps linear centroid v8.xyzw
dcl_output o0.xyzw
dcl_temps 7
add r0.x, -v4.z, l(1.000000)
add r0.x, -r0.x, l(1.000000)
div r0.yz, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[5].xxyx
mad r0.z, r0.x, r0.z, cb0[5].w
mad r1.x, v4.x, r0.y, cb0[5].z
add r1.y, -r0.z, l(1.000000)
add r0.y, -r1.y, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xyxx, t0.xyzw, s2
mul r1.x, r1.x, cb0[10].z
mad r1.z, -r0.y, cb0[10].w, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r0.y, r1.xzxx, t2.xyzw, s4
add r0.z, cb0[10].y, l(1.000000)
mul r0.w, cb0[10].y, l(0.500000)
mad_sat r0.y, r0.y, r0.z, -r0.w
mul_sat r0.y, r0.y, v7.y
div r0.zw, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[6].xxxy
mad r0.x, r0.x, r0.w, cb0[6].w
mad r1.x, v4.x, r0.z, cb0[6].z
add r1.y, -r0.x, l(1.000000)
sample_indexable(texture2d)(float,float,float,float) r1.xyzw, r1.xyxx, t1.xyzw, s3
add r1.xyzw, -r2.xyzw, r1.xyzw
mad r0.xyzw, r0.yyyy, r1.xyzw, r2.xyzw
mov r1.x, v5.w
mov r1.y, v6.w
sample_indexable(texture2d)(float,float,float,float) r2.xyz, r1.xyxx, t3.xyzw, s6
sample_indexable(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t4.xzwy, s5
mad r2.xyz, r2.xyzx, cb0[1].xyzx, cb0[2].xyzx
mul r2.xyz, r2.xyzx, cb0[3].xxxx
mul r0.xyz, r0.xyzx, r2.xyzx
add r2.xyz, v4.xyzx, -cb3[14].xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
rsq r2.w, r1.w
mad_sat r1.w, r1.w, cb1[21].x, cb1[21].y
mul r2.xyz, r2.wwww, r2.xyzx
dp3 r2.w, r2.xyzx, v2.xyzx
add r3.x, r2.w, r2.w
add r2.w, r2.w, l(1.000000)
max r2.w, r2.w, l(0.000000)
log r2.w, r2.w
mul r2.w, r2.w, cb0[8].z
exp r2.w, r2.w
min r2.w, r2.w, l(1.000000)
mad r2.xyz, v2.xyzx, -r3.xxxx, r2.xyzx
dp3_sat r2.x, r2.xyzx, cb1[10].xyzx
max r2.x, r2.x, l(0.000010)
log r2.x, r2.x
mul r2.x, r2.x, cb0[9].y
exp r2.x, r2.x
mul r0.w, r0.w, r2.x
add r2.x, -cb0[8].x, cb0[8].y
mad r2.x, r2.w, r2.x, cb0[8].x
mul r2.x, r2.x, cb0[9].x
add r1.xy, r1.xyxx, l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r2.yz, cb1[7].xxxx, r1.xxyx, l(0.000000, 1.000000, 1.000000, 0.000000)
mul r1.x, r1.x, cb1[7].x
mad r1.x, r1.x, l(0.500000), l(1.000000)
mul r1.y, r2.z, r2.x
mul r0.w, r0.w, r1.y
mov_sat r1.y, cb1[22].w
add r2.x, -r1.y, l(1.000000)
mul r1.w, r1.w, r2.x
mul r2.xw, cb2[0].zzzw, cb1[22].xxxx
add r3.y, -v1.y, v1.w
mov r3.x, v1.x
mad r2.xw, v1.wwww, r2.xxxw, r3.xxxy
div r3.xy, r3.xyxx, v1.wwww
sample_indexable(texture2d)(float,float,float,float) r3.x, r3.xyxx, t5.xyzw, s1
div r2.xw, r2.xxxw, v1.wwww
sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r2.xwxx, t6.xyzw, s10
add r2.x, -r4.x, l(1.000000)
mad r1.y, r1.y, r2.x, r4.x
add r1.z, -r1.y, r1.z
mad r1.y, r1.w, r1.z, r1.y
mul r0.w, r0.w, r1.y
mul r3.yzw, r0.wwww, cb1[11].xxyz
mul r2.xzw, r2.zzzz, cb1[20].xxyz
mad r1.zw, v4.xxxz, cb0[0].xxxy, l(0.000000, 0.000000, 0.500000, 0.500000)
sample_indexable(texture2d)(float,float,float,float) r5.xyz, r1.zwzz, t7.xyzw, s0
mad r2.xyz, r5.xyzx, r2.yyyy, r2.xzwx
mul r5.xyz, r4.yzwy, cb1[22].wwww
mad r4.xyz, r4.yzwy, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3_sat r0.w, v2.xyzx, cb1[4].xyzx
mul r6.xyz, r0.wwww, cb1[5].xyzx
mad r5.xyz, r6.xyzx, r1.yyyy, r5.xyzx
mad r0.w, r1.y, l(0.500000), l(0.500000)
mad r1.xyz, r5.xyzx, r1.xxxx, r2.xyzx
eq r1.w, cb1[22].w, l(0.000000)
and r2.xyz, r4.xyzx, r1.wwww
mad r1.xyz, r2.xyzx, r0.wwww, r1.xyzx
max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r0.xyz, r0.xyzx, r1.xyzx, r3.yzwy
mul r0.xyz, r3.xxxx, r0.xyzx
mad r0.xyz, r0.xyzx, v8.wwww, v8.xyzx
mul r1.xyz, r0.xyzx, cb1[0].zzzz
mad r0.xyz, r0.xyzx, cb1[0].xxxx, l(1.000000, 1.000000, 1.000000, 0.000000)
div o0.xyz, r1.xyzx, r0.xyzx
mov o0.w, cb0[12].z
ret
// Approximately 98 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/06/2015 05:06 PM   
oh ok, so you are trying to copy it from a pixel shader. Can you post the corresponding vertex shader (and domain and geometry shaders if they are used by this effect) so I can see where that texcoord would have come from? Also, that texcoord can potentially vary over the surface of the object, so can you tell me a little about what you are trying to achieve so I can try to offer the best advice? The way I see it there are three possibilities: - Assign a new render target that you can copy it to and sample that in another shader (suitable if you need the values copied on a per-pixel basis) - Determine how that texcoord is derived in the vertex/domain/geometry shader and copy that procedure and all necessary inputs to the destination shader where you will derive it from scratch. - (Needs a new 3DMigoto feature) Assign a buffer to the stream output stage of the pipeline to capture the texcoord output from the vertex/geometry shader directly (suitable if you need the values copied on a per-vertex basis). This will need non-trivial support added to 3DMigoto to work first, since the shaders need to have been created using a special call to indicate which outputs will be written to the buffer. At the moment you can assign a buffer to the stream output stage, but without this extra support it probably won't do anything useful (plus it's untested and we would probably first want the feature to create a new buffer from scratch to use in it).
oh ok, so you are trying to copy it from a pixel shader.

Can you post the corresponding vertex shader (and domain and geometry shaders if they are used by this effect) so I can see where that texcoord would have come from? Also, that texcoord can potentially vary over the surface of the object, so can you tell me a little about what you are trying to achieve so I can try to offer the best advice?

The way I see it there are three possibilities:

- Assign a new render target that you can copy it to and sample that in another shader (suitable if you need the values copied on a per-pixel basis)

- Determine how that texcoord is derived in the vertex/domain/geometry shader and copy that procedure and all necessary inputs to the destination shader where you will derive it from scratch.

- (Needs a new 3DMigoto feature) Assign a buffer to the stream output stage of the pipeline to capture the texcoord output from the vertex/geometry shader directly (suitable if you need the values copied on a per-vertex basis). This will need non-trivial support added to 3DMigoto to work first, since the shaders need to have been created using a special call to indicate which outputs will be written to the buffer. At the moment you can assign a buffer to the stream output stage, but without this extra support it probably won't do anything useful (plus it's untested and we would probably first want the feature to create a new buffer from scratch to use in it).

2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit

Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD

Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword

Posted 12/07/2015 01:05 AM   
I was trying to copy the blending ratio of a shore ground texture and use it as an alpha channel for the foam texture on the shore of a lake, but as you said, this value may be not always consistent. Currently I'm using a scaled depth buffer of a lake to add the foam effect, but this has it's drawbacks. It's better to show it on video. First recording is showing the effect I'm trying to achieve and the problem: when I move the camera the thickness of a foam changes, which is expectable for obvious reasons. Second movie is showing the scaled(value not size) depth buffer of a lake where you can see the problem more clearly. I was trying to compensate that using the viewport coordinates but with not 100% satisfying results. I've been struggling with that for the last 3 days, but options are limited. What I need is a shape of the surface of a lake with blurred edges maintaining perspective. I could show you the shader code but in the current state (experiment over another and another) it would be a pain to read it (needs a proper clean-up when I'm done with experimenting) If you have even the craziest ideas I'm all ears. https://www.youtube.com/watch?v=90WmNINRdp8 https://www.youtube.com/watch?v=o_lYlun0Tug
I was trying to copy the blending ratio of a shore ground texture and use it as an alpha channel for the foam texture on the shore of a lake, but as you said, this value may be not always consistent.

Currently I'm using a scaled depth buffer of a lake to add the foam effect, but this has it's drawbacks.
It's better to show it on video. First recording is showing the effect I'm trying to achieve and the problem: when I move the camera the thickness of a foam changes, which is expectable for obvious reasons. Second movie is showing the scaled(value not size) depth buffer of a lake where you can see the problem more clearly.

I was trying to compensate that using the viewport coordinates but with not 100% satisfying results.

I've been struggling with that for the last 3 days, but options are limited. What I need is a shape of the surface of a lake with blurred edges maintaining perspective.

I could show you the shader code but in the current state (experiment over another and another) it would be a pain to read it (needs a proper clean-up when I'm done with experimenting)

If you have even the craziest ideas I'm all ears.



EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/07/2015 02:20 AM   
how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable [Hunting] ; Release mode is with shader hunting disabled, optimized for speed. hunting=0 (change to hunting=1) ; Highlight mode of currently selected shader / rendertarget. ; "skip" = skip shader. don't render anything using the currently selected shader. ; "original" = fall back to original shader if the currently selected shader was patched. ; "mono" = disable stereo for the selected shader / rendertarget. ; "zero" = shader output is all zero. NOTE: this has a big performance impact. marking_mode=skip
how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable

[Hunting]

; Release mode is with shader hunting disabled, optimized for speed.
hunting=0 (change to hunting=1)

; Highlight mode of currently selected shader / rendertarget.
; "skip" = skip shader. don't render anything using the currently selected shader.
; "original" = fall back to original shader if the currently selected shader was patched.
; "mono" = disable stereo for the selected shader / rendertarget.
; "zero" = shader output is all zero. NOTE: this has a big performance impact.
marking_mode=skip

Posted 12/07/2015 03:43 AM   
  39 / 141    
Scroll To Top