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
distribution by ramp
2598 2 2- freaq
- Member
- 300 posts
- Joined: March 2011
- Offline
- jacob clark
- Member
- 665 posts
- Joined: July 2005
- Offline
- koen
- Member
- 793 posts
- Joined: April 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
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