Search Unity

Help Wanted Creating refraction in HDRP

Discussion in 'Shader Graph' started by strongbox3d, Jul 16, 2019.

  1. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    766
    Hello guys,

    I am creating an underwater surface with shader graph and HDRP, but I can't find anywhere in google, wiki, etc any explanation on how to create the refraction part of water. Could anyone here, shine a light on this?

    I am using the HDRP/Lit master.

    Regards,
    Carlos
     
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    543
    keeponshading likes this.
  3. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    500
    A simple refraction shader outside in you could do with shadergraph with similar nodes like this one


    In case you need an water volume where you can dive in and out there is crest for BuiltInRP(free), for LWRP (asset store). The HDRP version is not finished yet.


    I know you asked for an HDRP version but my all time favorit is this Unity port
    https://github.com/shanecelis/water-demo
    from the WEBGL original
    http://madebyevan.com/webgl-water/
    with everything.)
     
    Last edited: Jul 16, 2019
  4. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    766
    Hello Unity,

    I will check those links, thank you very much.

    Hello keepondshading,

    I watched that tutorial but it is for LWRP which is not what I am using, and it depends on a custom node that the author created for LWRP as well. Also it uses unlit master which is not what I need either.

    I appreciate your response though!

    Regards,
    Carlos
     
  5. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    500
    I should definately read more documentation.
    However you got the right links from the HDRP master himself.)
     
  6. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    766
    I check those links and neither tell anything about how to create refraction in HDRP lit master. So, isn't there anyway to do refractions on HDRP/lit using shader graph? Or am I missing something?

    The water shader in the second link, don't even use refraction

    Regards,
    Carlos
     
  7. kev42100

    kev42100

    Joined:
    Apr 17, 2010
    Posts:
    56
    I hope that Unity will release soon a sample project with various water shaders (shader graph): reflection or refraction only or reflection + refraction + caustics in HDRP
    Like the sample projects about Visual Graph, Lit Master node, etc etc..
    It's a feature so important. And as the HDRP is your best and new top-rendering, it would be really a must-have !
     
  8. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    766
    I really don't understand why unity has never put too much attention to water, pretty much everyone I know would benefit from a good water in Unity. It most be one of the most difficult things to achieve in this engine I guess!
     
  9. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    543
    Indeed, the documentation lack of information. We will update it

    There is a builtin refraction mode in the lit shader. But you are also free to implement your own with shader graph.

    On a lit.shader
    - Change surface Type to transparent
    - Go to transparency inputs
    - Select a refraction model (either sphere or box)
    - be sure opacity is not 1 otherwise you will not see any change. Move it to 0 mean the objects is fully refractive


    On HDRP/Lit shader graph
    - Open settings of master node
    - Change surface Type to transparent
    - Select a refraction model (either sphere or box)
    - be sure opacity is not 1 otherwise you will not see any change. Move it to 0 mean the objects is fully refractive

    Alternatively , you can simply create a HD SceneColor node which give you the scene color with different bluriness and do your own refraction effect.

    hope this help.
     
  10. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    766
    Hello SebLagarde,

    Thank you so much for your reply!

    When you say: "be sure opacity is not 1 otherwise you will not see any change. Move it to 0 mean the objects is fully refractive"... Do you mean "Alpha", because I don't see any property that reads "Opacity".

    Regards,
    Carlos
     
  11. SKoptev

    SKoptev

    Joined:
    Jan 15, 2019
    Posts:
    36
    But there is no "refraction model" option in LitMaster node:
    upload_2020-2-13_13-36-38.png
    HDRP v.7.1.5, Unity v.2019.3.0b4
    Maybe, I need to change someone in project settings?
    It will be great to have an option to use built-in implementation of refraction effect, if there is no need to create something very special by myself.

    For now, I just rewrite RefractionModelSphere+RefractionModelBox code as customNode and use it into ShaderGraph.

    Thanks in advance!
     
    Last edited: Feb 13, 2020
unityunity