Simple Eiffel - Simple SDF

12 views
Skip to first unread message

Liberty Lover

unread,
Jan 15, 2026, 2:20:52 PM (4 days ago) Jan 15
to Eiffel Users
  Just shipped something I hope you will enjoy.

  A procedural medieval village running at 60 FPS - rendered entirely through mathematics. No 3D models. No meshes. No textures. Every surface computed in real-time on the GPU.

  This is Signed Distance Field (SDF) ray marching, powered by Vulkan compute shaders.

  The twist? It's written in Eiffel.

  Yes, that Eiffel - the language that pioneered Design by Contract. Turns out those preconditions and postconditions are just as valuable when you're pushing pixels at 2 million rays per frame.

  This demo showcases two libraries from the Simple Eiffel ecosystem:
  → simple_vulkan - GPU compute made accessible
  → simple_sdf - Mathematical geometry primitives

  The entire scene is built from primitive shapes - boxes, spheres, cones - combined with boolean operations and smooth blending. The GPU evaluates these distance functions for every pixel, every frame.

  Modern Eiffel. Modern GPU. Classical software engineering principles.

  🎥 Watch the full flythrough on YouTube.

Liberty Lover

unread,
Jan 15, 2026, 2:40:30 PM (4 days ago) Jan 15
to eiffel...@googlegroups.com
Perhaps someone reading this will say, "Well, that's just a toy demo!" ... well ... until it's not.

I saw a video on my YouTube feed at about 9 AM EST and it inspired me, asking, "Can I do this SDF thing in Eiffel with Claude helping?"

The answer is: Simple SDF

Right now, Claude is busy planning out, implementing, and testing a cluster of new Eiffel classes that will be responsible for allowing one to build and compile shaders at design/build-time or at run-time. You might be wondering: How do the Shaders and the SDF work together?

The shaders interact with SDF through ray marching:

  1. SDF Primitives → Distance functions in GLSL:
  float sdSphere(vec3 p, float r) { return length(p) - r; }  // Distance to sphere
  float sdBox(vec3 p, vec3 b) { vec3 q = abs(p) - b; return length(max(q,0.0)); }

  2. Scene Composition → Boolean operations combine primitives:
  float sceneSDF(vec3 p) {
      float d = sdSphere(p - vec3(0,1,0), 1.0);  // Sphere at (0,1,0)
      d = min(d, sdBox(p - vec3(2,0.5,0), vec3(0.5)));  // Union with box
      return d;
  }


  3. Ray Marching → GPU iteratively steps along rays:
  vec3 ro = camera_pos;      // Ray origin
  vec3 rd = ray_direction;   // Ray direction
  float t = 0.0;             // Distance traveled

  for (int i = 0; i < 128; i++) {
      vec3 p = ro + rd * t;          // Current position
      float d = sceneSDF(p);         // Distance to nearest surface
      if (d < 0.001) break;          // Hit!
      t += d;                        // Safe to step this far
  }


  4. Shading → Compute normals from gradient, apply lighting.

  The Eiffel DSL will generate this GLSL automatically from SDF_SCENE objects.

---

GLSL (OpenGL Shading Language) is the C-like programming language used to write shaders for GPUs. Key points:

  - Purpose: Programs that run on the GPU for rendering/compute
  - Shader Types: Vertex, fragment, compute, geometry, tessellation
  - Compiled to SPIR-V: For Vulkan (what shaderc does)
  - Syntax: C-like with vector types (vec3, mat4), texture samplers
  - Example:
  #version 450
  layout(local_size_x = 16, local_size_y = 16) in;
  void main() {
      vec2 uv = gl_GlobalInvocationID.xy;
      // GPU parallel computation here
  }

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/eiffel-users/d01aeb89-779e-402c-823b-1d1e27ad783an%40googlegroups.com.

Liberty Lover

unread,
Jan 15, 2026, 2:47:13 PM (4 days ago) Jan 15
to eiffel...@googlegroups.com
The class that renders the "scene" in an EV_TITLED_WINDOW

image.png

image.png


On Thu, Jan 15, 2026 at 2:20 PM Liberty Lover <rix....@gmail.com> wrote:

Liberty Lover

unread,
Jan 15, 2026, 3:17:55 PM (4 days ago) Jan 15
to eiffel...@googlegroups.com
To address the Shader matter, I have created Simple ShaderC. Here's the summary of it all:

  Summary

  simple_shaderc (New Library)

  - Created README.md following simple_* pattern with logo, badges, quick start, features
  - Created docs/ folder with:
    - index.html - Full API reference and recipes
    - css/style.css - Shared ecosystem stylesheet
    - images/logo.png - Ecosystem logo
    - .nojekyll - GitHub Pages configuration
  - Initialized git repo and pushed to https://github.com/simple-eiffel/simple_shaderc

  simple_sdf (Updated)

  - Added GLSL DSL classes:
    - src/glsl/glsl_builder.e - Base GLSL code generation
    - src/glsl/sdf_glsl_builder.e - SDF-specific shader generation
  - Added demos:
    - demo/sdf_dynamic_demo.e - Runtime GLSL compilation demo
    - demo/sdf_vision_demo.e - Vision2-based renderer
  - Added src/visualization/vision/sdf_vision_renderer.e
  - Updated ECF with new targets
  - Updated .gitignore for bin/, media/, logs
  - Pushed to https://github.com/simple-eiffel/simple_sdf

  simple_vulkan (Updated)

  - Added shaders/dynamic_scene.spv - Example runtime-compiled shader
  - Pushed to https://github.com/simple-eiffel/simple_vulkan

On Thu, Jan 15, 2026 at 2:20 PM Liberty Lover <rix....@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages