Showing posts with label random. Show all posts
Showing posts with label random. Show all posts

Wednesday, 8 October 2025

random vellum rest length in houdini core

 To randomise the stretch rest length value on initialisation (not dynamic, it can't be animated like this). make a primitive wrangle between the vellum hair constraint and the solver.

I've used a connectivity node set to Primitives and changed the "class" attrib to "hairID". Here we affect the restlength value by multiplying it by some remapped randomness.

f@restlength*=fit01(chramp("remap",rand(@hairID)),chf("min"),chf("max"));



remap "probability" of random CHANDOM

rand(@ptnum) will give you a distribution between 0 and 1.
fit01 will let you remap this random value between a given minimum and maximum.

But what if you want to have more of the larger values, or mostly small values.. or even just the values inbetween?

We can remap the initial rand(@ptnum) using a chramp.

eg. chramp("remap",rand(@ptnum);

displaying the ramp will let us draw a curve and affect the values.
So below, we will have very few small values and mostly large ones. 
The code is - f@restlength*=fit01(chramp("remap",rand(@hairID)),chf("min"),chf("max"));
Pay attention to the brackets.



Friday, 12 April 2019

Select a random point from a group each frame

Some code snippets from Walter to use points from a group randomly, for emission (or other things)

In a Detail Attribute Wrangle-

int npts = npoints(0);
float keep = rand(@Time + 235.624) * npts;
i@keep = int(keep);

Every time step, a random point id is chosen as the "keep" point.

Then in a blast, we kill everything but the kept point

`detail(0, "keep", 0)`

Don't forget to invert the blast selection