Search Unity

Clamp Fresnel Effect in Texture

Discussion in 'Shaders' started by MatheusMarkies, Jan 10, 2020.

  1. MatheusMarkies

    MatheusMarkies

    Joined:
    Apr 16, 2017
    Posts:
    67
    Hello everyone.
    I'm using Shader Graph (I'm a beginner) to create an eye shader.
    I want to use the Fresnel Effect to create a Shadow Fade in the iris of the eye.
    But I can't position the effect only on the iris, for what when I move the camera the effect keep in the same place.

    I have it:


    Want this:

    The shadow only on the iris.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    First, Shader Graph subforum is this way:
    https://forum.unity.com/forums/shader-graph.346/

    Then you don't want a Fresnel.

    The Fresnel Effect refers to how a surface gets more reflective when viewed at a glancing angle rather than head on. In this case the node is giving you the mask a PBR shading model might use for blending between the surface color and a reflection. The node is comparing the view direction to the surface normal and giving you a gradient between 1 (perpendicular) and 0 (parallel). The power controls the falloff curve. When you're looking at a sphere, this means the edges of the sphere will be nearly white and the faces towards the camera will be nearly black. For computer graphics a Fresnel approximation is used for all sorts of effects unrelated to reflections, like glows or faking outlines, etc. The preview mesh for a node is a sphere, so you're getting a nice round shape. On a flat plane you wouldn't see anything at all unless it's turned away from you.

    What I think you want is a circular falloff in texture space. For that you want a distance node using the UVs and Vector2(0.5, 0.5), multiply that by two, and then use a power node to apply the curve to get the falloff you want.