Skip to main content

Objects

Introduction to Objects

Objects are the fundamental building blocks of the plre environment. They define the shapes and structures within a scene. Unlike traditional polygon-based modeling, raymarch objects are based on mathematical formulas, specifically Signed Distance Functions (SDFs). For more information about raymarch, please refer to IQ san's videos and website.

Incorporating External Resources

Through plre, users can seamlessly include shape definitions from external resources such as lygia. This vast repository of pre-defined shapes can be tapped into, ensuring that users don't always have to start from scratch. By importing or referencing these resources, a plethora of complex and beautiful structures can be incorporated into a scene effortlessly.

// without lygia
float U_box(vec3 pos) {
  vec3 d = abs(pos) - vec3(1.);
  return min(max(d.x, max(d.y, d.z)), 0.)
             + length(max(d, 0.));
}
// with lygia
#include "lygia/sdf/boxSDF.glsl"

float U_box(vec3 pos) {
  return boxSDF(pos, vec3(1.));
}

Crafting Unique Shapes with Mathematics

Users aren't limited to predefined shapes. If you understand the math behind it, you can craft any shape imaginable using SDFs. From basic shapes like spheres and cubes to more intricate fractals, the potential is limitless.

// It can be reproduced with the following code
#include "lygia/generative/fbm.glsl"

float U_formula(vec3 pos) {
  float f = fbm(pos);
  return pos.y - f;
}