How to make distortion in Unity + Shader forge?

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

1 Like

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

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

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:

4 Likes

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

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.

1 Like

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:

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

2 Likes

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

5 Likes

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

Thank you so much!!

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

I find it kind of frustrating/mystifying that there isn’t one simple, basic instructional video or example of how to create a basic distortion effect.
I appreciate all the help everyone has provided in this thread, but it doesn’t change the fact that I am unable to replicate any of these based on the information provided nor find anything online.
If anyone would be able to pass on any starting points regarding creating a distortion effect in Unity Shader Graph, I would very much appreciate it!

There is a difference beetween using grab pass and distorted UV’s.
But both works, grab pass is just more expensive