teleliq Posted May 18, 2015 Share Posted May 18, 2015 (edited) 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 May 18, 2015 by teleliq Quote Link to comment Share on other sites More sharing options...
mestela Posted May 18, 2015 Share Posted May 18, 2015 you can use the implicit st parameters mantra gives you for curves. t is down the length of the curve, s is across the width. curve_shader.hipnc 1 Quote Link to comment Share on other sites More sharing options...
fuat Posted May 18, 2015 Share Posted May 18, 2015 (edited) 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 May 18, 2015 by fuat 2 Quote Link to comment Share on other sites More sharing options...
teleliq Posted May 18, 2015 Author Share Posted May 18, 2015 Thanks Fuat! Works like a charm, even if i don't unstand exactly how the uv node creates those values. But however....i'm here to learn this stuff. Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Yader Posted May 19, 2015 Share Posted May 19, 2015 (edited) 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. Edited May 19, 2015 by Yader 2 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.