Unreal world position offset question

Hey everyone! I have a vertex offset question that is giving me some trouble in Unreal. Does anyone know how to set up vertex offset that is local to the mesh instead of world space? I want to offset verts by vertex normal local to the mesh if that makes sense, so that when I rotate an object in the world the vertex offset rotates and stays consistent to the mesh. Right now, if I rotate the object that has the vertex offset, that vertex offset will change and go in different directions based on the objects rotation/position :frowning: which is great for some things, but not when I want to have this offset applied to the same objects in a scene all rotated at different angles.

To provide an example, say I am using a vector 3 with some sin waves plugged into x and I want that vertex offset to stay consistent no matter the rotation of the mesh.

Does anyone have a solution to this? I tried a transform vector (world to local) node receiving VertexNormalWS but that didn’t seem to do the trick for me.

you sound like you’re close - if you want to move verts along the vertex normal you just need to multiply the VertexNormal by a value and plug that into the WPO input - they’ll move in local space.

I did write up some tutorials on WPO a little while back - Unreal 4 World Position Offset — tharle VFX they might be able to help you.

Could you post a screenshot if you can’t get it to work? Very hard to see what’s going on without one.

Yeah I can grab a screenshot of what is happening. Yeah I have everything set up to work and vertex offset is working fine and is being multiplied by VertexNormalWS, it’s just the rotation of those meshes in the level that messes with it. It doesn’t seem to be applying the vertex offset locally to the mesh in the sense that whatever the rotation of the mesh the vertex offset will be the same and the mesh will look the same, just rotated. I’ll try and post a screenshot in a little bit if I can’t get it to work with some more tweaking. In other engines I have been able to multiply by vertex normal and not have these issues with rotating the mesh, but unreal seems to treat it slightly different or I might be missing a setting somewhere.

Here is a screenshot. I think the issue stems from my use of a vector 3 to determine specific directions of vertex movement with those append nodes. I want to have different vertex offset for each direction, however, it must be taking that vector 3 and interpreting it as world space or something like that? I basically want to affect the x, y, and z vertex movement separately while still being local to the mesh and staying the same no matter the rotation of the mesh.

In the screenshot the stuff going into the append nodes are textures and sin waves.

I’ll post an update if I am able to figure it out. Or if anyone has any suggestions let me know!

So you probably are exceptionally close, what you want to do is transform from localspace into worldspace.

There is a node called “Transform”. In the details of this node you can set the input to localspace and the out to worldspace.

You would probably want to put that after the Multiply by 10 and before the multiply by the worldspace vertex normals.

It is possible that you may need to do something to get the vertexnormals in localspace, but I don’t think that should be necessary.

Hi sam, try the tranformPosition node, that could help.

i think there might be a confusion in terminology here - if you’re applying the offsets locally then they should all look the same regardless of the rotation…

if you wanted everything to respond to the same thing (ie some candles all moving due to the same wind, regardless of rotation) then you’d just use world space values…

could you explain what effect you’re trying to achieve?

Thanks for the suggestions guys! I’ve tried all sorts of combos and the one that is currently working is using the transform node after the vector 3 transforming from local to world space and actually not multiplying by VertexNormalWS. Doing this keeps my directional vertex offset looking the same no matter the rotation of the mesh.

Hi, I’ve been having this same issue but when I do this it creates an offset in the mesh… any clue as in what’s going on?

And the offset depends on the world position, so if I move it around in the scene, the offset changes. If I connect anything else that isn’t the VertexNormalsWS node to the SplitComponents node (like that ObjectPosition or a WorldPosition node) the offset happens too.

P.S. Sorry for reviving such an old thread, for some reason I thought the date was saying June 17th, not June from 2017 :sweat_smile:

By mere luck I found the solution. Just gotta subtract it from the Absolute World Position. I don’t know why or how, but it works.

Now my only questions that remains is how to make this work inside a particle system… (it doesn’t seem to respect the changes that these nodes are doing)

You can try to change your Transformations into (or from) MeshParticle Space, that might fix your issue. Also whenever you are using ObjectPosition or ActorPosition, replace it with ParticlePosition.
In addition always use Niagara, not Cascade, Cascade had some issues with WorldPositionOffsets if I remember correctly.

Could you elaborate what exactly is not working and how your materrial network looks like?

Hi! Thanks for your input
If I try using MeshParticleSpace (in any order on that TransformPosition node) then none of the deformations happen and the mesh becomes stiff.
I can’t use Niagara because this is for a game project that’s been in development for some time and the art director doesn’t want to risk adding this new system and having it explode in our faces, I would also prefer to avoid causing a disaster. So we’ll just use it for next project but not this one.
I would love to show you how it’s behaving but because of NDA I can’t. I can show you my nodes though:

The problem is that the deformations are still happening in world space while in a particle system, so if I rotate the particle system instead of doing a zig zag motion the mesh is behaving more like a worm for example.

The solution I posted above only works when the model is used outside of a particle system, so I made a couple of blueprints to imitate what a particle system would do.

if it is inside a particle system you have to use ParticlePositionWS. It won’t work with ObjectPosition as Priareos already stated.
Subtracting the position in the same space was the right move to get the correct local (center) position. But saying “I don’t know why or how” shows me that you have to invest some time into your vector maths because that is one of the first steps that one learns :wink:
(I’ll leave a link for that: Chapter 2: Vectors (Immersive Linear Algebra))

You also state that “the offset depends on the world position”, which I do not quite understand. For me an offset is a value that gets added somewhere (mostly at the end), to have the animation “start” at a different position. Because how you describe what it should do, it sounds like it should make the animation super jittery.

Extra: Keep in mind that particles just know the information giving by the emitter on birth and then just now about themselves.

No need to be patronizing. If I didn’t understand vectors I wouldn’t have this job nor be able to do what I’m doing. It is possible to understand vectors and still don’t know why or how a problem is happening.

I tried ParticlePositionWS as well as others from the very beginning and any other that isn’t ObjectPosition doesn’t fix the issue and it adds an offset that isn’t fixable with the subtraction I showed before. So ObjectPosition is the only one that gives me a correct position even inside the particle system. It’s not the position that is the problem, it’s the rotation.

What I mean with “the offset depends on the world position” is that if you move the object around then the mesh offset changes, only being at the correct position when the pivot point is at origin. For example, if I move it to the right the mesh will move to the right exponentially, same if I do it for any other direction.

What you are describing (moving exponentially further, the further away from origin) is usually because you are adding the object or world position every time you are adding an offset. So it adds the offset + it’s own position. If that makes sense.

So, I’ve done some testing and I think you can maybe get rid of all of your Object Position + Transformation etc. As you are plugging it into the WorldPositionOFFSET, you are already adding it and don’t need to do it before. Then, as it will offset in world space, you will have to multiply with the object orientation (static mesh) or the particle direction (cascade mesh particle), so it adds the offset correctly. (Or you multiply with vertex normal, but then it’s on a vertex level, not an object level).

If you are then applying this material to your MeshParticles, it should just work (assuming they are Velocity Aligned). Not sure about the diagonal jaw movement stuff, but I’m sure we can figure out a different way.

EDIT: Also just saw this post, might help you out as well?

And this talk from the Abzu guys is quite cool when it comes to vertex anim movement

I’m seeing this just now, this seems promising, I’ll check it out when I have some free time. Thank you! :slight_smile: