I am trying to render a grid of spheres using ray marching. The SDF function looks like:
float sq_layer(vec3 p, vec3 bounding_box_min, vec3 bounding_box_max)
{
float cell_size = 4.0 / 16.0;
vec3 p0 = clamp(p.xyz, bounding_box_min, bounding_box_max);
p0 = mod(p0, cell_size) - cell_size * 0.5f;
float d_pt = sphereSDF(vec3(p0.x, p0.y, p0.z), 0.05f)
return d_pt;
}
But I am getting something like this:
For some more relevance, I tried changing the code up a bit:
float sq_layer(vec3 p, vec3 bounding_box_min, vec3 bounding_box_max)
{
vec3 cell_size = (bounding_box_max - bounding_box_min) / 4.0;
vec3 p0 = clamp(p.xyz, bounding_box_min, bounding_box_max);
p0 = mod(p0, cell_size) - cell_size * 0.5f;
float d_pt = boxSDF(p0, cell_size * 0.35);
return d_pt;
}