Search Unity

Question Water Shader Shoreline, foam. My math is bad

Discussion in 'Shader Graph' started by dec04, Apr 25, 2019.

  1. dec04

    dec04

    Joined:
    Jan 31, 2013
    Posts:
    9
    Hello, guys. I'm broken.
    I create this shader with shader graph. I read all the tutorials i could find.But! i can't fix this!


    Why my foam line moves when wave coming?? How fix it. Explain to me please.

    Full shader

    And please tell me, shader graph have alternative Depth Fade node like ASE or Shader Forge?
     
  2. dec04

    dec04

    Joined:
    Jan 31, 2013
    Posts:
    9
    Anyone?
     
  3. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
  4. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
    In vertex shader:
    Code (CSharp):
    1. output.screenPos = ComputeScreenPos(clipSpaceVertPosition);
    In fragment shader:
    Code (CSharp):
    1. float m_depth = LinearEyeDepth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(input.screenPos)));
    2.     float diff = saturate(_WaterDepth * (m_depth - input.screenPos.w));
    3.     float alpha = lerp(0.0, 1.0, diff);