Signed distance field raymarching in Godot 4, authored with nodes. Physics-driven metaballs melt into the SDF cubes in one fullscreen pass, and since every CSG op works on (color, distance) pairs, the colors blend along with the shapes.

Two free editions: Standalone shader (CC0): one .gdshader, no scripts paste onto a QuadMesh, edit map(). Godot Shaders https://godotshaders.com/shader/fullscreen-sdf-raymarching-with-smooth-csg-and-depth/

Node-based project (MIT): shapes as Node3D nodes, live editor preview, physics, up to 32 primitives and a write-up. VavLabs Mit
https://vav-labs.com/case-studies/sdf-raymarcher-godot/

Distance functions after Inigo Quilez.

youtube: https://youtu.be/Y1sd9Cx4NAs

  • insomniac_lemon@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    up to 32 primitives

    This seems very low unless it’s nuanced or multiple tricks can be used. Joined operations/volumes/surfaces, scheduled calculations etc. So I’d like to see what can be implemented in more examples.

    The SIGGRAPH talk for PixelJunk Shooter 2 covers things like this albeit 2D, distance fields are used for the walls (2, static+dynamic, merged into 1), different shader techniques for liquids.

    • Stratos@programming.devOP
      link
      fedilink
      arrow-up
      3
      ·
      3 months ago

      32 is a deliberate ceiling for this edition, not a limit of the technique. The design goal was set no compute no buffers one file shapes travel as uniform arrays, and every primitive adds a distance eval to every march step on every pixel, so a fully analytic field doesn’t want hundreds anyway. The scaling tricks are exactly the ones you list bake everything static into a precomputed SDF texture and sample it as a single primitive. That’s the natural direction for the node based edition if it grows to v2

      Hadn’t seen the liquids part of that SIGGRAPH talk thanks for the pointer, watching it.