Water Shader Refraction Part

Node-based Shader Editor

Water Shader Refraction Part

Postby Desoxi » Sun Nov 12, 2017 4:18 pm

Hello there,
just bought the plugin for unity and im trying a few things around.
At the moment im recreating the water shader from the samples and one part is a bit weird though.
Working refraction: https://imgur.com/a/U5Zx8
Not working refraction: https://imgur.com/a/vyeAh

The first one uses the component mask node but doesnt mask it at all (seen by the xyzw text). This nodesystem works well and i think the refraction looks good.
But as you can see in the second screenshot, which uses the component mask to use only xy, the refraction is not correct anymore. The sample nodesystem uses the same mask (xy) and when you start the sample scene everything is ok.
As soon as you switch the mask node to xyzw and back to xy again the sample scene as well does not work as intended anymore.

The only difference i could find in the generated code is the following:

Mask (xyzw, which is working as intended):
Code: Select all
float4 screenColor17 = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD( ( (ase_screenPos26).xyzw + float4( ( _Distortion * temp_output_15_0 ) , 0.0 ) ) ) );


Mask (xy, looks wrong):
Code: Select all
float4 screenColor17 = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD( float4( ( float3( (ase_screenPos26).xy ,  0.0 ) + ( _Distortion * temp_output_15_0 ) ) , 0.0 ) ) );


Dont know whether or not this is a bug, but if its not, i would appreciate it if you could explain it to me so i can understand how this works.
Desoxi
 
Posts: 9
Joined: Sat Nov 11, 2017 10:35 pm

Re: Water Shader Refraction Part

Postby Desoxi » Sun Nov 12, 2017 4:24 pm

Alright i guess i just figured out why this doesnt seem to work.
The UNITY_PROJ_COORD function needs a 4 component vector. And i think the W component is important in here because of perspective division. And if we use a "XY" component mask this W component is most likely to become 0 which would screw things up in perspective division.
Am i right?
Desoxi
 
Posts: 9
Joined: Sat Nov 11, 2017 10:35 pm

Re: Water Shader Refraction Part

Postby Amplify_Borba » Mon Nov 13, 2017 10:20 am

Hello,

Thank you for reporting this issue and for the detailed explanation, we'll be running some tests on our side and get back to you as soon as possible!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Water Shader Refraction Part

Postby Ricardo Teixeira » Thu Nov 16, 2017 2:50 pm

Desoxi wrote:Alright i guess i just figured out why this doesnt seem to work.
The UNITY_PROJ_COORD function needs a 4 component vector. And i think the W component is important in here because of perspective division. And if we use a "XY" component mask this W component is most likely to become 0 which would screw things up in perspective division.
Am i right?


Greetings,

This is not an issue with the component mask node, so to speak, Grab screen color node UV inputs changes whether the input is a vector2 or a vector4 and does some different calculations. Changing the connected nodes changes the connection from vector3 to vector4 changing the input to a vector4 but then changing it back to vector3 again does not trigger the change because it's not a vector2. (backwards compatibility purposes)

We're going to leave this issue pending because this behavior might not be relevant anymore or maybe we can think of a better solution while maintaining backwards compatibility.

Apologies for the inconvenience.
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 7 guests