Creating refraction in HDRP

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

Hi please, see the documentation: Redirecting to latest version of com.unity.render-pipelines.high-definition

alternate method is to use shader graph with a SampleSceneColor node and do your own refraction.

There is various thread on the forum talking about refraction. there is water for hdrp thrread as well: HDRP Water Shader Graph (Github link)

hope this help.

1 Like

A simple refraction shader outside in you could do with shadergraph with similar nodes like this one

https://www.youtube.com/watch?v=-7UmfKUb1Zg

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.)

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

I should definately read more documentation.
However you got the right links from the HDRP master himself.)

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

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 !

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!

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.

1 Like

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

But there is no “refraction model” option in LitMaster node:
5475630--560289--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!