distribution by ramp

   2540   2   2
User Avatar
Member
300 posts
Joined: 3月 2011
Offline
trying to control a randomness by a ramp parameter

so an artist can control what spawns more often and less
my idea is to take the curve, integrate it (or via numpy .cumsum())
and then index that value.

but apparantly this is not so easy in houdini,
some pointers anyone?

edit:
weird:
when storing a ramp as a variable the ramp cannot be adressed:

this works:
hou.parm('/obj/lot1/distribution2').eval().lookup(0.7)

this does not:
dist = hou.parm('/obj/lot1/distribution2').eval()
dist.lookup(0.3)

which makes it very inconveniant to do things like integrate etc.
very nasty
User Avatar
Member
665 posts
Joined: 7月 2005
Offline
Check the attribute randomize sop. One of the options if for ‘Custom Ramp’.

It's a complex node, but it's great!
User Avatar
Member
792 posts
Joined: 4月 2020
Offline
I think the custom attribute ramp still is “remapping” the result, you sort of want the transposed graph.

I usualy solve this with rejection sampling, for example, in an attribwrangle:



// If there is an id attribute
// use that for the random seed,
// else just use the point nr
int seed;
if (isbound(“id”)){
seed = @id;
}
else{
seed = @ptnum;
}

// start with a random number
float random_nr = random(seed);

// test if this number works with the ramp,
// if not, reject the sample and try again
while(random(int(100000*random_nr)) > chramp(“dist”, random_nr))
{
seed = seed+1234;
random_nr = random(seed);
}

// sample is fine, let's set the scale
@pscale = random_nr;


cheers,
Koen
  • Quick Links