Shiney Surface shader and fog shader help
Hi This shader seems to effect shiny surfaces - it renders slightly wrong I am being fussy but the shader looks broken: it has o2.z = 0.000000000e+000; That's wrong right? Or is it just how the shader handles real numbers? Here is the shader. Is there anyway to fix it? I don't mind tweaking but would be really greatful for a demo of which part(s) needs to be tweaked. :) [code]// Shiney Surfaces cbuffer cb0 : register(b0) { float4 cb0[3] : packoffset(c0); } Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( float4 v0 : POSITION0, float4 v1 : TEXCOORD0, out float2 o0 : TEXCOORD0, out float3 o1 : TEXCOORD1, out float4 o2 : SV_Position0) { float4 r0; uint4 bitmask, uiDest; float4 fDest; o0.xy = v1.xy; r0.xy = v1.xy; r0.z = 1.000000000e+000; o1.x = dot(cb0[0].xyw, r0.xyz); o1.y = dot(cb0[1].xyw, r0.xyz); o1.z = dot(cb0[2].xyw, r0.xyz); o2.xyw = v0.xyw; o2.z = 0.000000000e+000; return; } [/code] also DarkStarSword mentioned experimenting with part of this fog shader because the standard pattern didn't work for some reason. (I didn't ask which part.) I would be greatful for an example of the section I need to tweak. [code]//Fog in asteroid cbuffer cb0 : register(b0) { float4 cb0[11] : packoffset(c0); } cbuffer cb1 : register(b1) { float4 cb1[12] : packoffset(c0); } Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( float4 v0 : TEXCOORD0, out float4 o0 : TEXCOORD0, out float3 o1 : TEXCOORD1, out float3 o2 : TEXCOORD2, out float2 o3 : TEXCOORD3, out float4 o4 : SV_Position0) { float4 r0,r1,r2; uint4 bitmask, uiDest; float4 fDest; r0.xyz = cb0[4].xyz + -cb0[3].xyz; r1.x = cb1[9].y; r1.y = cb1[10].y; r1.z = cb1[11].y; r0.w = dot(r1.xyz, r1.xyz); r0.w = rsqrt(r0.w); r1.xyz = r1.xyz * r0.www; r2.xyz = cb0[3].xyz + -cb0[0].xyz; r0.w = dot(r2.xyz, r1.xyz); r2.xyz = r1.xyz * -r0.www + -r2.xyz; r0.xyz = r1.xyz * -r0.www + r0.xyz; o1.xyz = r1.xyz; r0.w = dot(r2.xyz, r2.xyz); r0.w = sqrt(r0.w); r0.w = -cb0[4].w + r0.w; r1.x = dot(cb0[1].xyz, r0.xyz); r0.xyz = -r1.xxx * cb0[1].xyz + r0.xyz; r0.x = dot(r0.xyz, r0.xyz); r0.x = sqrt(r0.x); r0.x = -cb0[3].w + r0.x; r0.x = max(r0.x, 0.000000000e+000); r0.y = r1.x < 0.000000000e+000; r0.z = r0.y ? cb0[10].x : cb0[10].y; r0.x = r0.x * r0.z; r0.x = saturate(r0.x / abs(r1.x)); r0.z = 9.999999747e-006 < abs(r1.x); r1.x = 2.000000000e+000 + -r0.x; r0.x = r0.y ? r1.x : r0.x; r0.x = r0.z ? r0.x : 1.000000000e+000; r0.y = 0.000000 != cb0[5].z; o0.w = r0.y ? r0.x : 1.000000000e+000; r1.xy = v0.xy; r1.zw = float2(1.000000e+000,1.000000e+000); o4.xyzw = r1.xyzw; // Apply a stereo correction to the temporary register that holds a copy of the // output position: float4 stereo = StereoParams.Load(0); r1.x += stereo.x * (r1.w - stereo.y); o0.xyzw = r1.xyzw; r0.xyz = cb0[7].xyz * v0.yyy; r0.xyz = v0.xxx * cb0[6].xyz + r0.xyz; r0.xyz = cb0[8].xyz + r0.xyz; o2.xyz = cb0[9].xyz + r0.xyz; r0.x = cb0[5].x + -cb0[4].w; o3.y = saturate(r0.w / r0.x); o3.x = cb0[5].y; //Disabled Shader //o4=0; return; } [/code] Many thanks in advance! :)
Hi

This shader seems to effect shiny surfaces - it renders slightly wrong

I am being fussy but the shader looks broken: it has o2.z = 0.000000000e+000; That's wrong right? Or is it just how the shader handles real numbers?

Here is the shader. Is there anyway to fix it? I don't mind tweaking but would be really greatful for a demo of which part(s) needs to be tweaked. :)

// Shiney Surfaces

cbuffer cb0 : register(b0)
{
float4 cb0[3] : packoffset(c0);
}

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

void main(
float4 v0 : POSITION0,
float4 v1 : TEXCOORD0,
out float2 o0 : TEXCOORD0,
out float3 o1 : TEXCOORD1,
out float4 o2 : SV_Position0)
{
float4 r0;
uint4 bitmask, uiDest;
float4 fDest;

o0.xy = v1.xy;
r0.xy = v1.xy;
r0.z = 1.000000000e+000;
o1.x = dot(cb0[0].xyw, r0.xyz);
o1.y = dot(cb0[1].xyw, r0.xyz);
o1.z = dot(cb0[2].xyw, r0.xyz);
o2.xyw = v0.xyw;
o2.z = 0.000000000e+000;
return;
}



also DarkStarSword mentioned experimenting with part of this fog shader because the standard pattern didn't work for some reason. (I didn't ask which part.) I would be greatful for an example of the section I need to tweak.
//Fog in asteroid
cbuffer cb0 : register(b0)
{
float4 cb0[11] : packoffset(c0);
}

cbuffer cb1 : register(b1)
{
float4 cb1[12] : packoffset(c0);
}

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

void main(
float4 v0 : TEXCOORD0,
out float4 o0 : TEXCOORD0,
out float3 o1 : TEXCOORD1,
out float3 o2 : TEXCOORD2,
out float2 o3 : TEXCOORD3,
out float4 o4 : SV_Position0)
{
float4 r0,r1,r2;
uint4 bitmask, uiDest;
float4 fDest;

r0.xyz = cb0[4].xyz + -cb0[3].xyz;
r1.x = cb1[9].y;
r1.y = cb1[10].y;
r1.z = cb1[11].y;
r0.w = dot(r1.xyz, r1.xyz);
r0.w = rsqrt(r0.w);
r1.xyz = r1.xyz * r0.www;
r2.xyz = cb0[3].xyz + -cb0[0].xyz;
r0.w = dot(r2.xyz, r1.xyz);
r2.xyz = r1.xyz * -r0.www + -r2.xyz;
r0.xyz = r1.xyz * -r0.www + r0.xyz;
o1.xyz = r1.xyz;
r0.w = dot(r2.xyz, r2.xyz);
r0.w = sqrt(r0.w);
r0.w = -cb0[4].w + r0.w;
r1.x = dot(cb0[1].xyz, r0.xyz);
r0.xyz = -r1.xxx * cb0[1].xyz + r0.xyz;
r0.x = dot(r0.xyz, r0.xyz);
r0.x = sqrt(r0.x);
r0.x = -cb0[3].w + r0.x;
r0.x = max(r0.x, 0.000000000e+000);
r0.y = r1.x < 0.000000000e+000;
r0.z = r0.y ? cb0[10].x : cb0[10].y;
r0.x = r0.x * r0.z;
r0.x = saturate(r0.x / abs(r1.x));
r0.z = 9.999999747e-006 < abs(r1.x);
r1.x = 2.000000000e+000 + -r0.x;
r0.x = r0.y ? r1.x : r0.x;
r0.x = r0.z ? r0.x : 1.000000000e+000;
r0.y = 0.000000 != cb0[5].z;
o0.w = r0.y ? r0.x : 1.000000000e+000;
r1.xy = v0.xy;
r1.zw = float2(1.000000e+000,1.000000e+000);



o4.xyzw = r1.xyzw;

// Apply a stereo correction to the temporary register that holds a copy of the
// output position:
float4 stereo = StereoParams.Load(0);
r1.x += stereo.x * (r1.w - stereo.y);

o0.xyzw = r1.xyzw;
r0.xyz = cb0[7].xyz * v0.yyy;
r0.xyz = v0.xxx * cb0[6].xyz + r0.xyz;
r0.xyz = cb0[8].xyz + r0.xyz;
o2.xyz = cb0[9].xyz + r0.xyz;
r0.x = cb0[5].x + -cb0[4].w;
o3.y = saturate(r0.w / r0.x);
o3.x = cb0[5].y;

//Disabled Shader
//o4=0;

return;
}


Many thanks in advance! :)

Lord, grant me the serenity to accept the things I cannot change, the courage to change the things I can, and the wisdom to know the difference.
-------------------
Vitals: Windows 7 64bit, i5 2500 @ 4.4ghz, SLI GTX670, 8GB, Viewsonic VX2268WM

Handy Driver Discussion
Helix Mod - community fixes
Bo3b's Shaderhacker School - How to fix 3D in games
3dsolutionsgaming.com - videos, reviews and 3D fixes

#1
Posted 02/07/2016 08:43 PM   
By the looks of how simple the vertex shader is, the shiny shader is likely a deferred shader and might need a fix in the pixel shader - you will need to perform experiments to find potential places you can adjust it. For experimentation, I will usually just add a value to x coordinates at random various and observe what happens. I use an IniParam set to transition from 0 to 1 over 1 second so I can see more clearly what the change is doing. Sometimes I multiply the experimental value by StereoParams.Load(0).x so that it will move in opposite directions in each eye. You are trying to find spots where you are able to move the effect horizontally with respect to the camera (regardless of camera orientation), but if you find a spot where you are able to move it in a cardinal direction (e.g. north-south) with respect to the world that is interesting as well. For a few places to start experimenting - try adjusting each of the output registers at the end of the vertex shader (or sometimes inputs at the start). Look for anything that might be a matrix multiply (four 'dot' product instructions using consecutive constant registers) and try on the coordinate before and after that.
By the looks of how simple the vertex shader is, the shiny shader is likely a deferred shader and might need a fix in the pixel shader - you will need to perform experiments to find potential places you can adjust it.

For experimentation, I will usually just add a value to x coordinates at random various and observe what happens. I use an IniParam set to transition from 0 to 1 over 1 second so I can see more clearly what the change is doing. Sometimes I multiply the experimental value by StereoParams.Load(0).x so that it will move in opposite directions in each eye. You are trying to find spots where you are able to move the effect horizontally with respect to the camera (regardless of camera orientation), but if you find a spot where you are able to move it in a cardinal direction (e.g. north-south) with respect to the world that is interesting as well.

For a few places to start experimenting - try adjusting each of the output registers at the end of the vertex shader (or sometimes inputs at the start). Look for anything that might be a matrix multiply (four 'dot' product instructions using consecutive constant registers) and try on the coordinate before and after that.

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

#2
Posted 02/08/2016 01:14 AM   
Thanks for this :) Am I right in thinking, once it looks like the shader has done its calculations I can add multipliers and it doesn't matter if the wxyz part of the wxyz is split over a couple of lines? Re Fog shader - 2nd one above I added multipliers for the fog VS. It's a weird one, with the fore and midground being fine but the extreme distance looking too near. Is it possible to stretch out the depth of a shader? If so what part of the shader would I be looking at tweaking? (The second shader in the OP.) With regard to PSs they look different to VSs. The output looks different. Is there a way to fix using copy and paste patterns like you can do with VSs? Finally you mentioned four dots, but most of the time there are only bunches of three like in the first example above (there is only one set in this one though) could I just add the forth, including the extra coordinate and adding one to the packoffset at the top? e.g. [code]float4 cb0[4] : packoffset(c0); o1.x = dot(cb0[0].xywz, r0.xyzw); o1.y = dot(cb0[1].xywz, r0.xyzw); o1.z = dot(cb0[2].xywz, r0.xyzw); o1.w = dot(cb0[3].xywz, r0.xyzw); [/code] I clearly have no idea what I am doing; pure guess work :/ Thanks in advance!
Thanks for this :)

Am I right in thinking, once it looks like the shader has done its calculations I can add multipliers and it doesn't matter if the wxyz part of the wxyz is split over a couple of lines?

Re Fog shader - 2nd one above
I added multipliers for the fog VS. It's a weird one, with the fore and midground being fine but the extreme distance looking too near. Is it possible to stretch out the depth of a shader? If so what part of the shader would I be looking at tweaking? (The second shader in the OP.)

With regard to PSs they look different to VSs. The output looks different. Is there a way to fix using copy and paste patterns like you can do with VSs?

Finally you mentioned four dots, but most of the time there are only bunches of three like in the first example above (there is only one set in this one though) could I just add the forth, including the extra coordinate and adding one to the packoffset at the top? e.g.

float4 cb0[4] : packoffset(c0);

o1.x = dot(cb0[0].xywz, r0.xyzw);
o1.y = dot(cb0[1].xywz, r0.xyzw);
o1.z = dot(cb0[2].xywz, r0.xyzw);
o1.w = dot(cb0[3].xywz, r0.xyzw);


I clearly have no idea what I am doing; pure guess work :/

Thanks in advance!

Lord, grant me the serenity to accept the things I cannot change, the courage to change the things I can, and the wisdom to know the difference.
-------------------
Vitals: Windows 7 64bit, i5 2500 @ 4.4ghz, SLI GTX670, 8GB, Viewsonic VX2268WM

Handy Driver Discussion
Helix Mod - community fixes
Bo3b's Shaderhacker School - How to fix 3D in games
3dsolutionsgaming.com - videos, reviews and 3D fixes

#3
Posted 02/09/2016 08:14 AM   
Scroll To Top