How to move a colour ramp texture along a mesh?

A (hopefully) really simple one here:

I have an instanced curve along which I want to move a colour ramp. I have this, but it moves the colour ramp in x (I’ve animated the x in the Mapping node, which is obviously wrong), not along the U or V of the mesh:

I know there’s a simple way to move it along the curve, but I’ve thrown all kinds of mapping nodes and stuff at it, with no success! Any suggestions, please, anyone?!

Thanks for any help!!

So.. you might try the UV- and not the Generated–coordinates ? :wink:

If I do that, then changing the Location: X just increases or decreases the overall brightness of the texture and does not move it. I did wonder if I’m seeing a massively scaled-up version of the gradient, and changing the X is actually moving it, and it appears to be increasing or decreasing in brightness because I’m seeing different parts of the gradient, but playing with the Scale values in the Mapping node did not actually scale the texture - again, it just changed the brightness.

So it seems that the mapping node is not affecting the mapping at all.

I may have been a bit quick when reading about UV and seeing the coordinates.. also maybe about the curve and/ or mesh.. but..

You may have to elaborate this to get a more suited answer (showing you mesh curve ??).

That’s pretty much what I’ve got (plus a lot of stuff to duplicate variations of the texture on instances), but if you adjust the X / Y / Z in your mapping node, it’ll move the texture around in XYZ space, not along the U or V (well, that’s what happens to me). Which means that if your curve/tube is bent in various directions, the texture will sweep across it in the world/model X-axis, not along its length. I just need to be able to access the UV origin of where Blender is putting the gradient texture and animate that. Surely that’s possible?

Here’s the curve:

…and this is what happens when I animate the texture along the X-axis (predictably)

I could (I presume) unwrap/create a UV map and animate that, but surely there’s a simple way to just say to Blender “make the UV origin of this texture animate from 0,0 to 0,1”?

This is the Geometry Node setup to create the instanced curves:

…and this is the complete texture node setup which assigns a random colour to the ramp:

You can store spline length (or factor) as a named attribute in geometry nodes, then use that in the shader nodes.

Not sure how to go about that…

Would I add a Store Named Attribute at the end of my Geo Nodes, like this maybe?

…then get that attribute and plug it into the Mapping node maybe?? (This doesn’t do anything useful by the way - I’m just guessing here!)

I may not understand what you are talking about.. :thinking: the gradient is along “the length of” the curve:

That (what you’ve created) is precisely what I want, but my gradient is always drawn along the X axis, not along the tube’s length. Why might that be, do you think??

As a test, I created a completely new scene, and made this, which works perfectly, exactly as your setup:

I wondered if it’s to do with converting it to a mesh in my main (problem) scene, but then I went back to that problem scene, and created a new Bezier curve, added some Bevel thickness (why oh why is it called “bevel”??!) and applied that ‘problem’ material, and it works ok, so I wonder why it’s not working on my main mesh?

Well.. now looing at your geometry nodes.. you are using a curve line from 0,0,0 to 0,0,0… ??? and then instancing your input curve with some circle profile.. i may not completely understand this yet.. but it seems the whole setup is not using the UV from that curve ??

I also did not understand why the (totla ) length of the curve should give the actual position “within” the curve..

( Just now only using my internet PC with blender3.6 which is also tells me “Input geo unsupporeted type mesh”.. but that may be my problem for now.. :sweat_smile: )

Yes, you need to Capture Attribute the UV

You capture the spline parameter, either factor or length:

Capture it before converting the curve to a mesh (because after converting, there is no spline to capture the factor/length anymore.

Then in the shader you get the attribute and subtract some value from it fo move it along the cuves:

You animate the subtracted value to make it move along:

I actually already have a similar geometry nodes setup to what you need, I think. I’ll share the blend file here in a minute.

Here’s what I have, maybe it’s useful to you:

It has a bunch of settings you can tweak, like number of ‘strands’ (splines), divided into ‘primary’ and ‘secondary’ (just a way to have two independent groups of strands that can have different settings and materials), ‘beam’ shape (it can be ‘flat’ like a ribbon or 3D), and more:

MultipleStrandFiber_V3.blend (2.4 MB)

Wow - thank you!! I’ll have good dig around that geo nodes setup - pretty complex and awesome!

And yes - your “Subtract” node in the Shader Editor works exactly as expected! Weird how mine just refused to work. I’m still fairly convinced it might be something to do with my model being a mesh, not a spline or something. Maybe.

I am not that familiar with materials so I messed around a bit and figured out a way to get some more control using the position of another object (In this case, an empty).

…Aaaand one last question: What would be the best way to assign a different colour to some/all of the strands in your wonderful scene?

I tried using my previous Object Info (Random) > Colour Ramp (Constant) ? Mix Colour, but that didn’t work; I guess there isn’t ‘object info’ for each of the strands. This (on my previous version) enabled me to set a palette of those 3 colours in the Ramp, and it would tint the strands at random, which was nice:

I’m not sure. I think I would start by trying to store the spline indexes as a named attribute in geometry nodes and then doing some math with it in the shader nodes.

Actually, ignore that last one; I decided to have one last go at building it myself, so did pretty much exactly the same process…except this time, it worked!

The only difference was this:

In my previous attempts, I created a Bezier curve, and did everything else (including, crucially, giving it some thickness using a Profile Curve in the Curve to Mesh node) in Geo Nodes.

In the more recent, successful attempt, I added thickness to the curves with an inappropriately-named Bevel in the Bezier Curve’s Object Data Properties panel before embarking on the Geo Nodes. Now I have the issue that I’d like to randomise the thickness of the tubes, and because I didn’t give them thickness in a Geo Node, that might be tricky!

Thanks @Ale_GM for all your help! I’m always astounded by how wonderful everyone on Blender Artists is! :two_hearts: