Search Unity

Question Reverse fresnel effect and differences between code and shadergraph node

Discussion in 'Shader Graph' started by Neogene, Jan 29, 2020.

  1. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    95
    Hi,

    i was trying to invert (white to black -> black to white) the Fresnel effect to use to create a "trasparent in the middle effect", i tried using negate, multiply, remap and other nodes without success, so i took a look to the source code (right click on Fresnel node) and tried to replicate the source code with shader graph nodes, but i'm missing something 'cause the result is different.

    Unity_FresnelEffect_float(IN.WorldSpaceNormal, IN.WorldSpaceViewDirection, 1, _FresnelEffect_8897A24E_Out_3);

    invokes :

    void Unity_FresnelEffect_float(float3 Normal, float3 ViewDir, float Power, out float Out)
    {
    Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(ViewDir)))), Power);
    }

     
  2. Elizabeth_LeGros

    Elizabeth_LeGros

    Unity Technologies

    Joined:
    Jan 7, 2020
    Posts:
    50
    Hi!
    For clarity, you already tried doing
    1 - fresnel
    and it wasn't giving you the appearance you were looking for, correct?
    Also, looking at your provided graph, it looks like you are using the saturation node, NOT the saturate node which may be why you are getting different results than the fresnel effect node
    upload_2020-1-29_15-35-26.png
     
  3. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    95
    Thank you for the reply, i did that error and replaced the node, but without success: i noticed your normal and view direction previews are different, value preview colors seems moor smooth in yout preview, and the boxes don't display the sphere preview you are showing, i'm using LWRP and latest shader graph.

    Ok the missing preview and wrong preview during flow are due to Shader Graph installed on 2019.2.x v. 6.9.2



    In 2019.3 which has ShaderGraph 7.1.8 the "flat previews" problem doesn't happen:

     
    Last edited: Jan 30, 2020
  4. Elizabeth_LeGros

    Elizabeth_LeGros

    Unity Technologies

    Joined:
    Jan 7, 2020
    Posts:
    50
    Okay, so then part of the issue may be a bug fixed between 6.9.2 and 7.1.8. I assume an upgrade of project version is out of the question?
    If you create the graph and apply it to a material in game, does it show the same problem as what shows up in the graph view? The graph view and the material in game use different shaders so this might just be a graph view only issue
     
  5. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    95
    No we can't move, and I received an answer from support after opening the ticket : "this bug probably won't be fixed in 6.9.x and is because is "a cosmetic bug"". This make developing shader graph with latest 2019.2 version a mess. thank you, we will continue to go with "try if works" behavior...