Distortion shader

Hi, I´m working on a distortion shader using niagara, there should be a stream of particles inside the distortion effect, I´m guessing its not vivible because I´m using the scenecolor node and the particles itself arnt part of the scene???

Hi cesaraugusto,
if the stream of particles is a separate emitter in the same niagara system as your distortion shader, you should be able to fix your issue by changing the “Sort Order Hint” of your emitters so that emitter using the distortion has a lower value then the other particles.
If the stream of particles is in a separate system you can change the “Translucency Sort Priority” to be higher then the one with the distortion shader in the Details panel. (But doing this will break unreal’s default distance based translucency sort order for all translucent objects with regards to the ones sort priorities you change)
Edit: You could also use “Translucency Sort Distance Offset” to fudge the distance sorting without totally breaking it

I’m curious why you’re using this method to get distortion instead of using refraction.
Hope this is helpful.

The reason why it doesn’t work, is because translucent particles written in AfterDOF do not get merged into the scene buffer. Instead they have their own buffer which will be merged into the backbuffer in post processing.
(Also you would have to read from the buffer you’re currently writing to, so that’s not gonna happen)

There are 2 methods to implementing distort on translucent elements :
1 : Draw the elements you want to distort in the BeforeDOF translucency pass. In this case both refraction, and translucent effects in AfterDOF will be able to affect these elements.

2 : [super advanced] Add (get a programmer to add) a separate pass after Translucency which merges the SeparateTranslucency buffers and SceneColor into a MergedSceneColor buffer and a pass after that in which you can sample from this new MergedSceneColor buffer using the SceneColor node.

1 Like

Hi Michael, well, I used this method because using refraction wouldnt allow me to mix in a fresnel node in the shader and I didnt wanted te effect to look in a cylindrical form which is the static shape I´m using the shader on right now. However, I´m very new at shaders and I´m trying to up my vfx level using them, if you know any other faster and easier method to accomplish this; it would help me a lot.
Regarding this specific case, I have all emitters in the same system and changing the sort order hint on the emitters worked and made the particles visible, however, the shader wont distort the particles itself, is there a way to make it distort the particles as well… ?
Thanks for your time!

Hey Niels thanks for your time and for the help.
I´m super newbie with sahders and overall with a lot of unreal stuff so I couldn´t find the settings yo´re mentioning. Do you have any kind of learning material about that so I can have a better grasp on this?
What Ipm trying to accomplish is that a shader used in an emitter distorts everyting behind it inluding particles from others emitters in th same system…
Appreciate the time :slight_smile:

Hey cesaraugusto,

Niels’ answer is the better of the two, my solution was what you get when you answer questions after midnight and more from the days of UE3, working around the issue instead of fixing it.

I couldn’t get the BeforeDOF solution to work with your distortion setup, but it does work with refraction.

First thing to do is go into the translucent materials you want effected by the distortion material and in the material settings Translucent> Advanced>Translucency Pass>Before DOF (note that the tool tip is off and says “Render after depth of field.” for both Before and After DOF settings)

For the refraction in your distortion material I would change it like this:

This will let your particle color alpha control the amount of distortion in the range of the lerp.
Good info on refraction in the unreal docs including indexes of real world things: Using Refraction in Unreal Engine | Unreal Engine 5.0 Documentation

hope that clears things up

1 Like

Yes! This worked perfectly, and for some reason this time it allowed me to use the fresnel node, I´ll look more into that. :smiley:
Thanks for you both Michael and Niels !:smiley: