Building Worlds With Distance Functions in GLSL (Raymarching)





Article index:


7 – Raymarching: Floor + Rounded Box minus Sphere

Build Worlds With Distance Functions in GLSL, GLSL Hacker
Raymarching: floor + rounded box minus sphere

The function to substract two primitives:

vec2 op_sub(vec2 a, vec2 b)
{
  float d = max(a.x, -b.x);
  return vec2(d,1);
}

And the distance_to_obj() function:

vec2 distance_to_obj(in vec3 p)
{
  return obj_union(obj_floor(p), op_sub(obj_round_box(p), obj_sphere(p)));
}






Article index:


Pages: 1 2 3 4 5 6 7 8 9




Geeks3D.com

↑ Grab this Headline Animator