Gradient material along spline

Hi there,
Is there a way to adjust a gradient map (linear gradient node in base color) along a whole spline while using spline mesh component ?

If I simply set a LinearGradient as a diffuse in a material, that gradient repeats for each mesh added along the spline (basically one mesh between 2 points of the spline). I want one single gradient along the whole spline length.
Thanks a lot !

1 Like

I think, in case you want really smooth gradient from 1st to last spline mesh, the only way to do this - is use manually prepared set of material instances, and assign them one by one to spline meshes.

Well I don’t mean to prepare a fixed number of assets. I want to move a gradient mask along a spline - whatever the length or the path of the spline. I want to simulate a liquid flowing into a tube.

Actually the problem is that whatever the material I use, it is applied once for each spline mesh. I want to apply a map or adjust UVs to match the entire spline (ideally following spline UVs).

Alright here is one solution I just found :
In my material, I put a Linear Gradient function into the alpha input of a Lerp node. In A, set a scalar parameter (named Color_A), in B another one (named Color_B).
In the actor (just a spline component), I create spline mesh components for each segment as usual, and a dynamic material instance for each one. For each segment, I have to devine Color_A and Color_B so that the whole spline covers 0 to 1 (so ie 3 segments : one from 0 to 0,33, the second from 0,34 to 0,66, the third from 0,67 to 1).

See screenshots to figure it out easier.
Let’s I have to try this to use these values to UVs in order to use a mask…

And where is the difference between this and solution I proposed?

The same you assign material instance to every spline mesh and adjust its values. But in this case you use DynamicMaterialInstance which is little bit expensive than simple MI )))

I think if you need this for one particular asset in your game, it is better to make this curved model in 3dmax or so, and set it’s 2nd or 3rd UV channel for desired gradient.

Yeah after reflexion it looks similar. I’ve understood in your proposition that you said to make specific materials to manually apply to each segment. In my setup the whole thing is set on construction (so not so much expensive), adjusted if you move or add/delete some points.
I probably just misunderstood your proposition, thanks a lot though :wink:

That’s not the aim since the spline in my case has to bu adjusted along other actors placed in the editor (and I really don’t want to set the entire level in 3ds…).

Well, I imagine project which requires this for many objects, so I’ve tried to implement this by myself in my experimental project.

Solution is quite simple, so I was wrong with my first opinion.

This is what I get:

Of course it depends on mesh UVs and gradient orientation in material.

My material is very similar to yours:

261502-material.png

And here is blueprint for spline mesh actor:

2 Likes