Search Unity

Question HDRP refraction shader issues

Discussion in 'Shader Graph' started by BlackTheFall, Mar 11, 2021.

  1. BlackTheFall

    BlackTheFall

    Joined:
    Apr 11, 2014
    Posts:
    14
    Hello,

    I'm building a water shader with shader graph on HDRP. I'm using a simple refraction method: refraction_graph.png

    It works fine, refracts as it should until, a bung of steps later, hen I'm, adding the part for the foam (a simple depth mask for the contact edge with the shore added to a broader shoreline mask - also a depth mask). Somewhere around this point the refraction brakes:
    refraction_graph2.png
    before -> after​
    And that's it, it breaks. Can't undo, recompile doesn't work, deleting the foam part of the shader does nothing, nor clearing cache, restarting unity/computer/whole apartment etc. I can't even make a new refract shader because it behaves the same way. The only thing that works is one of my initial shaders.
    I took that one and tried to rebuild the extra steps that I had in the broken one and when I added the foam it broke -> go to previous loop.
    Does anyone have a clue about what might cause such a behavior?

    Thank you!

    P.S. here's the foam culprit:
    upload_2021-3-11_2-13-16.png
     
  2. BlackTheFall

    BlackTheFall

    Joined:
    Apr 11, 2014
    Posts:
    14
    Solved - it was my fault - one of the water colors had alpha and that added transparency on top of my alpha calculation. That, in its turn, screed with how refraction was applied to the scene.

    In case you encounter such "anomalies", make sure your alpha masks are properly calculated and make sure to check the color nodes for alpha (by default alpha is set to 0).

    Cheers!