Skip to content

Instantly share code, notes, and snippets.

@mimetaur
Created June 19, 2018 22:40
Show Gist options
  • Select an option

  • Save mimetaur/19afaf884d363fa71de9104b4758ac2c to your computer and use it in GitHub Desktop.

Select an option

Save mimetaur/19afaf884d363fa71de9104b4758ac2c to your computer and use it in GitHub Desktop.
Sketch 1 / Create Points Attribute Wrangle
// paramaters come in as floats by default
// in order to cast them to other types
// need to wrap them in a "set()"
int width = set(ch("width"));
int height = set(ch("height"));
int num_points = set(ch("num_points"));
int seed = set(ch("seed"));
// seed needs to be persisted
// down the line as an attributes
// to remain available to future geometry
i@seed = seed;
for (int i = 0; i < num_points; i++)
{
// if we just used "rand(i)"
// without offsetting the random seeds differently
// we end up with a diagonal line of points
float random_remap_x = fit(rand(seed+i), 0, 1, -0.5, 0.5);
float random_remap_y = fit(rand(seed-i), 0, 1, -0.5, 0.5);
float xpos = random_remap_x * width;
float zpos = random_remap_y * height;
vector position = set(xpos, 0, zpos);
// http://www.sidefx.com/docs/houdini/vex/functions/addpoint.html
addpoint(0, position);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment