Material for PoseableMesh with dynamic lenght

Hi,

I’m doing a trajectory line of dynamic length and dynamic number of visible bones with a PoseableMesh. I want to have a nice gradient at the end of the line. Say that I have a total of 40 bones, but maybe only using 20. Then the last 20 will have the same position as the last valid bone. Also the length of each bone will differ.

So now I’m doing a simple gradient with just a TexCoord and a mask (attached image). But then there is basically no gradient, since UVs are based on same bone length - and half of UV space is in one point…

So how can I do a constant gradient, eg. 1 -> 0 during last X units of the complete line?

Thanks!

//Jonas

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into it for you.

Can you please send us a minimal test project that demonstrates this, and include screenshots of the issue?

The guide for test projects:

[Content removed]

Hi Sarma,

Attaching a simple project. Basically just setting the first bones positions with a constant distance (except the last), and the last bone further away. And the material to use textcoord and a mask. I want the line to have a color and constant fading - eg. transparency 1->0 constantly along the line

Now I see that my skm looks a bit strange, not sure if I misunderstood how to use the skm, or if it’s simply wrong. First time using bones so my model file might be wrong… But still it looks as each bone get a constant faded color instead of fading along the bone.

The input data I have is points in 3d space. Do I need to adjust each bone length also, so it’s length is between the points also? As of now the bones seems to overlap.

Thanks!

//Jonas

Hello,

You want the Origin to be one end of the mesh and the Terminus to be the opposite to evaluate any given point in-between.

One approach is to use these values:

Origin = Local bounds minimum

Terminus = Local bounds maximum

T = Currently evaluated local position

implementation in your material:

  1. Add a local bounds node. Take Min as your Origin and Max as Terminus
  2. Add a local position node. Take the XYZ for T
  3. Add a subtract node. Pass Terminus to A and Origin to B. This is the distance of your gradient.
  4. Pass the distance to a normalize node and also to a length node.
  5. Add a dot product node. Pass T to A and normalized distance to B.
  6. Add a divide node. Pass the dot product above to A and the length of your distance to B.

The output of these operations should be a smooth gradient traveling from one end of the mesh to the other. From here, you can do whatever you want with the result, like adding it to a lerp node to transition between two arbitrary colors.

[Image Removed]

You could also adjust the gradient in various ways, such as adding a subtract node to the local position to shift the gradient around.

You could also make the Origin and Terminus into parameters and pass arbitrary values into them from a blueprint, custom primitive data, etc.

For example, you could pass the position of a bone as the Terminus.

How you elaborate on or adjust this technique will depend on the goals you have for this mesh.

Here is an example material setup.

[Image Removed]

Please let us know if this helps.

Super! Been of a couple of days, will have a look this week

Thanks!!

//Jonas

Hey!

it’s busy times before vacation, so not sure I will manage to check this now. Answer looking good, so OK to close ticket. I’ll get back if I have more questions!

Thanks!

//Jonas

Hello,

I will close this ticket for now. Please feel free to re-open the case if you have additional questions.