How to color points along with new Point SOP

   3743   2   3
User Avatar
Member
43 posts
Joined: Jan. 2014
Offline
OK so this may be a silly question. I've been away from Houdini for a while and this is something I always used to do using a Point SOP as it was just easier, but as H is moving towards VEX more a lot more nodes, i'd like to do the same.

Say I had a line with a number of points, normally I would drop a POINT SOP, Add Color and just use

1-$PT/$NPT in R, G or B and this would give me a nice ramp from Red to Black. How do I achieve this in an new Attribute Expression node?
User Avatar
Member
8525 posts
Joined: July 2007
Online
to get really full 1-0 ramp on sequentially ordered curve it'd have to be 1-$PT/($NPT-1)
which in the new Point SOP will be
1.0-@ptnum/(@numpt-1.0)
if however your curve has scrambled point order or you have multiple curves in the input and you want 1-0 ramp on each of them then you can use
1.0-vertexprimindex(0,@vtxnum)/(primvertexcount(0,@primnum)-1.0)

EDIT:
and if the real question was how to do that only for one of the channels, then you can for example do:
{1,0,0}*(1.0-@ptnum/(@numpt-1.0)) // to set just x and clear y and z
//or 
set(1.0-@ptnum/(@numpt-1.0), 0, 0) // the same 
//or
set(1.0-@ptnum/(@numpt-1.0), self.y, self.z) // to set just x, but keep y and z from input or at default values
//etc...
Edited by tamte - Oct. 12, 2017 11:02:12
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
43 posts
Joined: Jan. 2014
Offline
Awesome thanks!

The curves were created from points with a unique id and a Solver SOP so
1.0-@ptnum/(@numpt-1.0)
worked just fine, but that second piece of code will come in handy.
  • Quick Links