#Water Shader

1 messages · Page 1 of 1 (latest)

woeful hinge
#

Hello beautiful people. I'm currently playing with shader graph right now to make a distortion effect for water. I followed some tutorials on youtube but I want to really at least understand what I'm doing. I am playing with the Screen position and Screen Color nodes but I can't manage to distort what's behind a simple square. Can somebody take a look and tell me if I did something wrong ?

worthy oriole
# woeful hinge Hello beautiful people. I'm currently playing with shader graph right now to mak...

It looks like your using a Sprite graph type so I'd assume you're using URP's 2D Renderer?

If not, you should switch to a regular Unlit Graph type in the Graph Settings tab of the Graph Inspector. And check the values of your properties on the material.

If you are using the 2D Renderer, then afaik it doesn't support the Scene Color node as it uses the camera's "opaque texture" (screen captured between rendering opaque and transparent objects). Since sprites are all transparent, it doesn't bother capturing that texture.

If you really need a distortion effect in 2D, and have access to renderer features (I think in 2021.2+?), can blit (e.g. https://github.com/Cyanilux/URP_BlitRenderFeature) the screen/camera to your own texture ID, then obtain it via a global/unexposed texture property and sample that in the graph.
(or try blitting to _CameraOpaqueTexture and continue using scene color node, but haven't tested that)

But note you'd also need to make sure anything that uses that texture (e.g. your water sprite) is rendered in an event after that blit occurs. Maybe with the Render Objects feature, if that's supported in 2D.

woeful hinge
#

I followed a tutorial that does indeed add the Render Feature to ensure that the effect is visible but it doesn't work :/

#

What is blitting though ? 😄 Thank a lot for the detailed answer 🙂

worthy oriole
#

Blit basically means copy from one texture to another. In this case used to capture the camera view to a custom render texture ID.

#

It might help if you share which tutorial you are trying to follow

woeful hinge
#

Check out this very simple yet FUNKY Distortion Shader Graph tutorial with in depth explanation made in Unity 2019 LTS.

TIME STAMPS:
00:00​ FULL GRAPH PREVIEW
00:26 URP AND SHADER GRAPH SELECTION
00:50​ GRAPH SETUP - UV MOVEMENT
01:46 GRAPH SETUP - NOISE CREATION​
02:25 EXPLANATION VERTEX SHADER VS FRAGMENT SHADER
02:53​ USING THE FRAGMENT SH...

â–¶ Play video
woeful hinge
woeful hinge
#

Is there something I misunderstood or didn't set up correctly ?

woeful hinge
# worthy oriole It looks like your using a Sprite graph type so I'd assume you're using URP's 2D...

Hi there, I am the person who desired a distortion effect in the 2D renderer. I managed to make your custom blit feature work yesterday. If I choose Camera as the destination, the desired effect is visible on the entirety of the screen as expected. However when I choose Render Texture or Texture ID (and put the Screen Position as the UV), the effect is scaled down to the size of the affected zone (or this what at least think is happening). From your experience, do you know how I could avoid this downscaling ? If you don't have the time it's okay, it is not urgent. The solution you provided already wields some nice results so thank you for that !