# Randomize a grid from a Kinekt/Orbec camera

Hello, im using point data from a depth camera to generate particles using ParticlesGPU, everything is working perfectly but i cant seem to figure how to randomise the points coming form the depth camera.
Its coming in as a nice grid formation from the camera and I’m trying to “de-gridify” it to look more organic.

Its coming in as a TOP form the camera with a GLSL clipping box to get the data i want, does anyone have a neat solution to achieve what I’m trying to?

Thanks

Andy

One straightforward approach is to introduce random perturbations to the grid points. You can add small random offsets (in both X and Y directions) to each point’s position. This jittering will break up the regular grid pattern and create a more natural distribution.

vec2 jitter = vec2(rand(seed), rand(seed)); // Generate random offsets
vec2 degridifiedPos = originalPos + jitter;

The Halton sequence is a deterministic, low-discrepancy sequence that can be used for quasi-random sampling. It provides better coverage than purely random points. You can use the Halton sequence to perturb your grid points. Compute the Halton values for each point and add them as offsets. Cat blog

def halton_sequence(index, base):
result = 0.0
f = 1.0 / base
while index > 0:
result += f * (index % base)
index //= base
f /= base
return result

# Usage:

for i in range(num_points):
x_offset = halton_sequence(i, 2) * max_offset
y_offset = halton_sequence(i, 3) * max_offset
degridifiedPos = originalPos + vec2(x_offset, y_offset)

Hi Doria,

That’s brilliant, thanks for pointers.

Thanks

Andy