Vertex shader offset for spline interpolation

HI everyone!
I have a vertex offset question at UE4 material.
I want to deform a static mesh cylinder like a spline. I want to deform through a material.
I have spline data - start point, start tangent and end point, end tangent.

This is the UE4 engine source code that contains the spline interpolation formula.

I recalculated the position in World coordinates for each pixel.
How can I calculate the World Position Offset WPO in the material?

How to convert interpolated spline positon to world position offset in ue?

Just subtract interpolated spline world position from the original world position.

Nope. It’s doesnt work. I tried

  1. Original Mesh (green) without WPO

  2. World - Interpolated Spline Position = WPO. Deformed mesh incorrect.

  3. Interpolated Spline Position - World = WPO. Mesh moves somhere. I cant see it

I’d say multiply by a variable and start with low numbers so you can see where it goes.
Debug from there.

Note : You should not need to explicitely choose without offset in the world position node since it will be sampled on the vs. At that point no offset should have been applied yet.

I found one bug in the my interpolation function. Now I have corrected it. But still I don’t get the correct deformation.

const float A2 = A * A;
const float A3 = A2 * A;
return (((2 * A3)-(3 * A2)+1) * P0) + ((A3-(2 * A2)+A) * T0) + ((A3-A2) * T1) + (((-2 * A3)+(3 * A2)) * P1);

  1. Thin lines are Spline Components
  2. Thick lines are cylinders with deformation through the material. (The start and end points that are used in the material are taken from splines)
  3. The position of the spheres is calculated through the interpolation function and it is correct.

I’m doing something wrong with position.

It works. Static meshes are fully consistent with splines. But when the actor rotates, it does not apply the rotation. Meshes remain in the same place.

Not an unreal expert here, no idea how to do specific things exactly but this sounds like instead of offsetting your calculated spline position by the original actors position (because that only handles position, not rotation or scaling) you need to do a full matrix transformation of you calculated spline points and then connect the output of that transform node into an absolute world position socket.

But when the actor rotates, it does not apply the rotation.
Try using the TransformPosition node to transform from Local to World instead of just subtracting the actor position

can u give example how to do it?

what exactly i need to transform from Local to World?

Without adding the actor’s position, the meshes stay in place when the actor’s position changes.


You are feeding in Local space parameters, so the spline algorithm is giving you local space coordinate outputs, hence why you have to pump in the object scale and position.
Instead of applying the transformations separately, feed it through a transform position node set to source = local space and target = world space to apply all the transforms at once. (including rotation)

This will give you a world space location of that spline point from which you can subtract your original world space to get the offset you need to get a vertex from it’s original position to it’s new position on the spline.

You’re next step after this is going to be to figure out some way to rotate and scale the mesh locally so it aligns with the direction of the spline.

1 Like

Thanks alot for help! I found solution! Works perfect!

I can calculate the direction at each spline point (blue arrow) after the deformation in local space.
I have information about the original vertex directions (red and yellow arrows).
How can I recalculate new vertex directions?