Color & randomisation

Stable Random per Point with rand(@ptnum)

Seed rand() off @ptnum for a 0..1 value that is different per point but stable frame to frame - the basis of most per-point variation.

What it does

Uses rand(@ptnum) to produce a random value that is unique per point but constant over time, because the seed (the point number) does not change frame to frame. Assigning it to a vector like @Cd seeds R, G and B independently.

When to use it

Use it for any per-point variation that should stay put: random colour, random scale, random offsets, random group membership. It is the seed you reach for before adding time or class-based variation.

The VEX code

// rand() of the point number is stable per point and per frame.
@Cd = rand(@ptnum);                       // vector: random RGB
f@size = fit01(rand(@ptnum), 0.5, 1.5);   // float: random scale
Context: paste this into an Attribute Wrangle running over points, unless noted otherwise.

Inputs and assumptions

Common mistakes

Frequently asked questions

Why use rand(@ptnum) instead of rand(@Time)?

@ptnum is stable per point, so the randomness stays put frame to frame. Seeding off @Time makes values change every frame, which flickers.

How do I randomise per piece instead of per point?

Seed off a per-piece attribute such as i@class or s@name (for example rand(i@class)) so every point in a piece gets the same value.

Open Houdini VEX Lab