Houdini Vex

Randomize Integer Attribute With Near Point Check

Randomize a point attribute with a near point search to maintain visual variation.  (High near_point_search_max may take longer to cache.) 

Vex:

// Assigns a i@attrs to each point. The s@custom_attribute_name will be from 0-i@value_max.

// For each point we'll pick an attr that is not the same as any of the closest points within i@near_point_search_max.

// Initialize an array that will hold the loop attr for each point.

int attrs[];

for (int i = 0; i < npoints(0); i++) {

    attrs[i] = -1;

}

// Loop over each point.

foreach (int i; int custom_attribute_name; attrs) {

    // Get the i@near_point_search_max closest points

    vector P = point(0, "P", i);

    int nearpts[] = nearpoints(0, P, 1, chi('near_point_search_max'));

    // Make an array of the loop attrs of the i@near_point_search_max closest points.

    int near_attrs[];

    foreach (int j; int near_pt; nearpts) {

        near_attrs[j] = attrs[nearpts[j]];

    }

    // Find the first attr that is not in the array of near_attrs.

    // Start at a random attr between 0 and value_max.

    int attr = int(rand(i+chi('value_seed')) * (chi('value_max')+1));

    while (find(near_attrs, attr) >= 0) {

        attr = (attr + 1) % chi('near_point_search_max');

    }

    // Assign the attr to the point.

    attrs[i] = attr;

    setpointattrib(0, chs('custom_attribute_name'), i, attr);  

UV Camera Point Cull

Remove points outside of camera view with option to add overscan values. 

Add a uvtexture node before point wrangle with Perspective from Camera, Attribute Class set to point, and Camera set to your render camera. 

Vex:

if(@uv.x<(0-ch('left'))||@uv.x>(1+ch('right'))) removepoint(0,@ptnum);

if(@uv.y<(0-ch('bottom'))||@uv.y>(1+ch('top'))) removepoint(0,@ptnum);

if(@uv.z<=0) removepoint(0,@ptnum);