Building Worlds With Distance Functions in GLSL (Raymarching)





Article index:


6 – Raymarching: Floor + Union of Rounded Box and Sphere

Build Worlds With Distance Functions in GLSL, GLSL Hacker
Raymarching: floor + union of a rounded box and a sphere

The function to get the union of two primitives:

vec2 op_union(vec2 a, vec2 b)
{
  float d = min(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_union(obj_round_box(p), obj_sphere(p)));  
}






Article index:


Pages: 1 2 3 4 5 6 7 8 9





[ Subscribe to Geeks3D latest news by email ]

Geeks3D.com

↑ Grab this Headline Animator