How to make distortion in Unity + Shader forge?

unity
distortion
tutorials

#1

Hello Everyone!! Distortion is the thing that I can`t really understand. I hope you will help and tell me how it works in Unity or generally, preferably with examples of different techniques.
Thank you for help!)))


#2

Hey Vitalo,

What do you intend to do with that Distortion? Do you want to emit distorted particles or do you have something else in mind?

Cheers


#3

Something like heat distortion, black hole, distortion on slash
example
power distortion
this dust O_O


#4

You could start using the Standard Particle Shader for those. It’s been introduced to Unity in 2017.1 (or .2 not sure anymore). It’s under Particles/Standard Unlit and has a checkbox where you can enable Distortion. All you need is a Normal Map for it.

Here is a simple setup that should work:


#5

Man, you save my life))) Thank you so much!!!


#6

Kind of a necro (sorry), but I’m wondering if anyone could point me in the right direction to create my own distortion shader with Unity’s Shader Graph.

Or any kind of info as to how distortion works, I’m very new to shaders in general.


#7

This is more for meshes than particles, but hopefully it’ll help get you started:

In unity’s shader graph, distortion works by grabbing a render pass and affecting the UVs. There’s a built in pass that the shader graph can access by default called the “_CameraOpaqueTexture” that grabs everything that’s not transparent. To grab this pass, you create a 2D texture that references the exact name of the pass. Then just plug that into a sample texture node.

distortion|690x370

In the shader graph you can mess with the UVs to add some distortion, in the example above I just threw some noise on there. When you apply that material, it’ll distort the image that would be behind it. For example, here’s a sphere with that material, in front of a couple trees:

distortion_on_a_shpere

I recommend playing around with this for a bit to get comfortable with it. But also keep in mind, if you need a better pass than the camera opaque texture, you can also create your own pass. There’s a lot of good examples on github, like here:

https://github.com/UnityTechnologies/LWRPScriptableRenderPass_ExampleLibrary!

The unity evangelist who created this repo, Andy Touch, is always posting really nifty examples of what can be done with the shader graph. Taking a look at his work will really speed you along on trying to learn shader graph stuff.


#8

I can only post one image at a time, so here’s the shader graph from above:


#9

CameraOpaqueTexture not work if you’re using HDRP by the way


#10

Thank you so much!!

I’ve seen his shader graph examples, I’ve totally missed the scriptable render pass ones though!