Jump to content

How to assign randomize colors to primitives using a ramp?


Recommended Posts

Hi guys, 

I have a pig head which I have sliced and packed, I am trying to randomize the color of each chunk by using a attribute random on the Cd, and a color node with a ramp from attribute after. 

The problem is that the color node doesn't assign the new colors to each chunk of the pighead, it mostly "overlays" it.

Thanks!

 

 

sample.PNG

frac.hip

Link to comment
Share on other sites

In a wrangle : 

// Get a random float between 0.0 and 1.0, and add a seed to test  and randomize per frame, or however you'd like
float randomFloat = rand(@primnum + 8439 + chi("seed"));

// Create a ramp (that you'll need to edit to rgb ramp in the interface parameters) and map the random float to it
// then output the random color mapped on the ramp to the Cd attribute
@Cd = chramp("color_ramp", randomFloat);

 

Link to comment
Share on other sites

You can also use the ramp from attribute feature built into the color node. This doesn't pick a "random" color, but bases the color selection from a ramp on the piece id. You could randomize the i@id attribute in the range of 0-piece_count for a truly random effect chosen from the ramp colors.

Untitled-1.jpg

ap_color_by_id.hiplc

  • Like 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...