My worst enemy...Transforms

Currently working in Unreal. My worst enemy is always transforms. I want to make a shader that moves the particles it’s applied to towards the camera. There were two ways I used to do this. One was I would push the pixel depth in the direction I needed. That was the easiest. It would cause particles to sort in front of or silhouette. But this option is not available for an additive or even a translucent material.

The other method I would use would be to create a plane that was offset on x axis and then I could scale on that axis to push or pull the plane and set the alignment to track with the camera. This is probably what I’ll end up doing again if no better ideas pop up.

So what I’ve been trying to do is a world position offset. The idea was that I would offset in either view space or local space and then transform to world. But for some reason it doesn’t seem to be working. I’m not sure what I’m doing wrong. The results seem to always be skewed towards the world origin.

I thought this might be a better place to bring this up instead of AnswerHub because it’s such an Fx related question.

Anyone ideas?

have you tried the camera offset node? I’m not sure when they added it but it does what you want i think - offsets the sprites towards the camera, to avoid things clipping where you don’t want.

https://docs.unrealengine.com/latest/INT/Engine/Rendering/ParticleSystems/Reference/Modules/Camera/

if you wanted to do some funky magic stuff and animate it, then all you need is to take the Particle Position away from the Camera Position (to get the Direction Vector from one to the other) and then multiply that by a value and plug it into the WPO input - a value of 1 will move the sprites to the camera position, so just scale it accordingly (use a Dynamic Parameter etc. etc.)

4 Likes

No. I haven’t seen these! Forest and trees.
Thanks!

Just FYI: Unity got a feature like this as well since version 2017.1

2 Likes

This sounds very interesting though I don’t really get what this is about :sweat_smile: maybe because there isn’t this kind of interaction between shaders and particles in Unity? Or is it just me who doesn’t know about it? So I would like to know more about this kind of dependence between camera, shaders and particles in Unity - do you happen to have a video or picture that shows an example of use of this feature? Maybe somewhere deep down your extensive website? :smiley:

This is from an article I’m preparing right now. Sometimes particles clip into object when spawned in their center/too near to them.

So a solution can be, to move the particle a little bit towards the viewer (aling the direction towards the camera) and with that avoid clipping.

Another cool trick is this: Imagine you spawn a lightsource at 0,0,0 and a particle at the same position. Since it’s not clear what comes first, in Unity the particle is NOT lit. When you move the particle a little bit away (agina, along tha camera-viewer-direction) the particle gets lit perfectly.

2 Likes

On devil may cry 5, we have used this extensively for all the impact effects.
Their were spawned on a socket inside the body of our characters, on the spine, but as Simon said, you don’t really want to see it clipping through the character.
You want your gameplay feedback very legible and an offset towards the camera position is just perfect.

2 Likes

I’ve used position offset to create silhouette effects too.

1 Like

Raise your hand if you’ve had trouble explaining velocity orientation to programmers.

Do you mean velocity aligned billboards?
Because a programmer would understand if you just explained how to align the axis: Have a forward axis aligning with the velocity vector and have an up axis orthogonal to the forward axis yet still planar with the vector between the center point of the billboard and the camera.

1 Like

you word good
thanks

Something about how I explained it made them say it was “geometrically impossible” even though i held up post-it notes and made them fly around on my fingers. :smiley: