2
$\begingroup$

Excuse me, I have a cube, which has a curve modifier applied to it. I want to create a material that goes along the curved mesh, like this image below:

enter image description here

Here is my setup, which doesn't work:

enter image description here

Edit: Setup with Curve ...

enter image description here

I hope my question makes sense.

Thank you so much Stay safe :)

$\endgroup$
5
  • 1
    $\begingroup$ for a circular shape you could us a Gradient node in Radial mode: blender.stackexchange.com/questions/200847/… ... if the curve is a more complicated shape I guess you need to apply the array and curve modifiers and use the UV otuput socket of the Texture Coordinate? $\endgroup$ – moonboots Nov 10 '20 at 6:13
  • $\begingroup$ What is the purpose to use a Cube? You can use just a Curve blender.stackexchange.com/a/201466/2214 $\endgroup$ – vklidu Nov 10 '20 at 8:09
  • $\begingroup$ @Ahmed, do you use an Array modifier? If so, apply it, also, use the Generated output socket of the Texture Coordinate $\endgroup$ – moonboots Nov 10 '20 at 8:52
  • $\begingroup$ You don't have in your node tree "Separate XYZ" node. If you want to go with Mapping node you have to setup there Rotate 90/135/0 and Scale X -3 or what ever that fits. $\endgroup$ – vklidu Nov 10 '20 at 18:18
  • $\begingroup$ What is the question now? Seems to be OK, when you switch to Render mode view it is there as expected. Changing X Scale moves colours (also nice effect with plugged Y. With your "Constant I just noticed - distances between control point matters. If you r looking for even distribution independent on curve's control points you would have to use curve (with even distribution) deformed by curve (your current) I will post it later if needed. Please delete your comments, chatting is not allowed here. If you have something important move it via edit into your question post. Thank you $\endgroup$ – vklidu Nov 11 '20 at 9:16
3
$\begingroup$

If you dont mind you can use just a Curve.

Shape

  • add Curve Circle, in edit mode Rotate 45, Duplicate and move 2.8 on X axis
  • select all vertices switch handles to Free V and delete from both circles the center segment
  • select end points and press F to connect

To get even distribution of colors you need to evenly distribut a curve's control points, that is not right now, but you can add another curve object - straight like, subdivide several times and deform this curve by previously shaped curve.

  • Add some stickness to curve (tube) - go to Properties editor > Object Data > Geometry > Bevel > Depth
  • It is better to keep curve in type Shape > 2D and Fill > None
  • Add Curve modifier (ensure origins both objects are at the same place)
  • Moving along X axis will move along shape

2.7x Material

  • Plug UV Texture Coordinate socket into Separate XYZ node
    and use X socket to lug into ColorRamp
  • Enable under Properties editor > Object Data > Texture Space > Use UV for mapping.

To see material switch to Rendered type view mode.

enter image description here

enter image description here

2.9x Material
is like here, you don't have to worry about UV in curve properties, it is set by default.


Notes:
Changing X Location will move gradient along curve. enter image description here

Changing X Scale in Mapping node will change gradient scale. enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Thank you so much for your detailed answer :) $\endgroup$ – Ahmed Nov 11 '20 at 13:02
  • $\begingroup$ @Ahmed Great it helped, just since you marekd as accepted, you should change the title to something neutral (mesh/curve) because you are asking a way with mesh and I aswered about curve. So dont get others confused. Thank you $\endgroup$ – vklidu Nov 11 '20 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.