Jump to content

Color ramp over the length of a curve (trail)


Recommended Posts

Hey Guys,

 

So first of all: Hi! My Name is Simon and I'm new to this forum and also pretty new to the Houdini world. Until now i did all my work in Cinema4D, but since i always liked to work very technical and play around with vectors, matrices and other stuff that a lot of people are scared of, i took a closer look at Houdini. And so far i love it. For practise, i try to rebuild some of my tools and setups i created in C4D using XPresso and Thinking Particles.

 

So i rebuilt a setup i made a few years ago (vimeo.com/52803528) where particles spawn on an object and are only allowed to make direction changes in 90° angles to build a gridlike structure. That part works great so far.

 

As a small addition, i wanted to colorize my trails based on their length. So for example that the tip is always green and the end is red. So basically a gradient over the length of the trail. Last week i found out that i can use the expression $PCT in a sweep node to get a value between 0 and 1 over the length to the backbone curve to scale the crossection. So i thought i could also use this expression to colorize the trails with a gradient. Sadly it seems, that this expression only works in the sweep node. Maybe i'm also wrong and overseeing something.

 

So if not, is there a simple way to colorize curves with a gradient based on their length? So that the start has color A and the end has color B?

 

 

Cheers,

Simon

Edited by teleliq
Link to comment
Share on other sites

Hi Simon,

Fuat here. There may be other solutions to this, but if you need it in the viewport also, this should work:

curve -> uvtexture SOP (Rows &Columns) -> attribVOP, dive inside, uv->vector2tofloat->fval1 (which should give you U along the curve) -> (input) ramp  -> Cd. done.

and dont forget to colorize you ramp to your needs one level up, of course. and the attribVOP has to run over vertices, since UVs are vertex-attributes.

 

no warranties, just off the bat.

hth

fuat

Edited by fuat
  • Like 2
Link to comment
Share on other sites

Here's another way using vertices, as those are connected to their respective primitive,

one handle each primitive (spline segment) individually. There you would set your Attribute

Create Node to use Vertex as the Class and type in $VTX/$NVTX for getting values going from 0 to 1

and after that use an Attribute Promote to get those values into the points Color. See screenshot.

 

After that just plug in a Color Node, set it to Ramp from Attribute, type in Cd as the attribute and

colorize to your hearts content.

post-7548-0-09541200-1432026526_thumb.pn

Edited by Yader
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...