Signed Distance Functions & Ray-Marching

Поділитися
Вставка
  • Опубліковано 22 тра 2024
  • Tell me how far away something is, and I tell you what it looks like!
    This one took a while. Mostly due to other things in my life. But also because I stumbled over quite a few problems when trying to implement SDFs for the animation. As a consequence, I learned more, but I also had to rewrite the script a lot to convey the things I learned properly. Still feels much rougher around the edges than my other videos.
    Moreover, this video is in 4k and 60 fps. Is it worth it? Doesn't make the development of the video much longer, so, I'll probably continue with it...
    Lastly, this video is also my submission for the Summer of Math Exposition 2023. If you search for #SoME3 on UA-cam, you will find many fantastic videos by the other participants!
    --------------------
    Join the Sum and Product Discord:
    / discord
    Follow Sum And Product on Twitter:
    / sumandproduct
    ...or Instagram:
    / sum_and_product
    Or buy me a coffee:
    ko-fi.com/sumandproduct
    --------------------
    Resources, references & further reading material:
    Animations were made with CindyJS:
    cindyjs.org/
    Signed Distance Functions on Wikipedia:
    en.wikipedia.org/wiki/Signed_...
    Octrees on Wikipedia:
    en.wikipedia.org/wiki/Octree
    Calculating perpendiculars via dot product:
    en.wikipedia.org/wiki/Vector_...
    Inigo Quilez' Website:
    iquilezles.org/
    Inigo Quilez' UA-cam channel:
    / @inigoquilez
    Inigo Quilez' article on wrong interior SDFs when using mimimums:
    iquilezles.org/articles/inter...
    Giovanni Russo & Smereka (2000), A Remark on Computing Distance Functions:
    www.sciencedirect.com/science...
    Phong reflection on Wikipedia:
    en.wikipedia.org/wiki/Phong_r...
    Blog post by Vassilis Poulopoulos on how to use SDFs to render text:
    renderdiagrams.org/2017/12/28...
    Music:
    "Shade" by Josh Woodward. Free download: joshwoodward.com/
    --------------------
    Chapters:
    [00:00] Introduction
    [01:36] Ray-Marching
    [04:51] Definition & Calculations
    [14:25] Manipulating SDFs
    [18:53] Basic Lighting & Actual Rendering

КОМЕНТАРІ • 31

  • @MusicEngineeer
    @MusicEngineeer 9 місяців тому +14

    Thank you. This may be very helpful for writing graphics rendering code.

    • @sumandproduct
      @sumandproduct  9 місяців тому +7

      I hope it will! When actually coding this, there are dozens of edge cases and practical problems to solve. But I hope that at least the mathematical foundation was made clear in the video.

  • @jurgenrichter-gebert
    @jurgenrichter-gebert 9 місяців тому +5

    WOW. Very smooth....Next Level! Literally!

  • @ryanjbuchanan
    @ryanjbuchanan 9 місяців тому +6

    Very well made video 😄

  • @cadenmccorvey4153
    @cadenmccorvey4153 4 місяці тому +1

    amazing video and extremely informative!

  • @VRchitecture
    @VRchitecture 9 місяців тому +2

    Lovely introduction! It’s nice you not only mentioned what SDFs are but also derived a couple of basics ones 👏🏻
    P.S. Though ray marching usage is pretty rare, typically we render “pre-baked” 3D geometry (stored as a list of vertices and normals not its mathematical description) with some sort of ray tracing.

  • @johnchessant3012
    @johnchessant3012 9 місяців тому +5

    Great video!

  • @Roxor128
    @Roxor128 9 місяців тому +11

    Ray-marching for collision-detection? Sounds useful. How to handle the different shapes of the objects involved, though? Could be a topic for a new video.

    • @sumandproduct
      @sumandproduct  9 місяців тому +4

      I've only used it for simple physics simulations where the objects moving around are small circles. But it's probably worth looking into more...

    • @Roxor128
      @Roxor128 9 місяців тому

      @@sumandproduct Yeah, I can see how you'd do sphere-anything collision. Subtract the sphere's radius from the SDF of whatever it might hit and then ray-march the same as if you're rendering the scene. Basically, making a rounded box and doing sphere-box collision would be the same process.
      The real headscratcher is how to handle other shapes and the potential rotation that would be introduced when they collide.

    • @sumandproduct
      @sumandproduct  9 місяців тому

      @@Roxor128 From what I learned during the research for this video, I wouldn't be surprised if checking for collision of two arbitrary SDFs is just not possible.

    • @bigfloppa9220
      @bigfloppa9220 9 місяців тому +2

      @@sumandproduct it is actually possible, but it requires gradient descent on the sdfs, and likely only works on true sdfs, not ones created using the unions of the shapes. it boils down to reducing the problem to the same one as colliding sphere sdfs, but by solving the system of equations formed by the two sdfs you are colliding. very possible, but time consuming and not very performant, as opposed to using bounding volumes to perform collision detection. There are several papers on it from Nvidia/other graphics researchers, and I think it probably does have it's place in physics simulations

    • @sumandproduct
      @sumandproduct  9 місяців тому

      @@bigfloppa9220 Oh, that makes sense, yes. Thank you!

  • @shadow15kryans23
    @shadow15kryans23 9 місяців тому +6

    This is a good video 👏

    • @CompanionCube
      @CompanionCube 8 місяців тому +1

      This is a good comment 👏

  • @oncedidactic
    @oncedidactic 8 місяців тому +1

    Very nice video! I learned a lot of new perspectives. As someone who works with spatial analysis tools on large datasets, I often wonder about how graphics approaches work versus the implementations of basic spatial relationship calculations. There is obviously much conceptual overlap, and I’m curious how many techniques are shared directly.

  • @torikenyon
    @torikenyon 9 місяців тому +4

    I’m confused, is just a different way to write the dot product, or is it something different?

  • @ValkyRiver
    @ValkyRiver 9 місяців тому +2

    How does ray marching work in spherical or hyperbolic geometries?

    • @sumandproduct
      @sumandproduct  9 місяців тому

      I imagine it works similarly whenever you have a metric.

  • @udderhippo
    @udderhippo 8 місяців тому +3

    Great video! Unsolicited English tip: pronounce "v" as a hard, sharp sound to differentiate it from the softer rounder "w". Don't be misled by the "v" character! In English it is pronounced like start of "wasser" in German.

  • @thecritiquer9407
    @thecritiquer9407 9 місяців тому +19

    finally a french competitor to 3blue1browm

    • @jurgenrichter-gebert
      @jurgenrichter-gebert 9 місяців тому

      @@markusa.stokkenes2271 He IS German ;-)

    • @notwithouttext
      @notwithouttext 9 місяців тому +1

      @@whannabi no they mean the COMPETITOR is french not the competitor's VIDEO

    • @notwithouttext
      @notwithouttext 9 місяців тому +6

      although, i think they're german, since the channel is in germany

    • @ArnaudMEURET
      @ArnaudMEURET 6 місяців тому +1

      Doesn’t sound French at all. German. France produced Fabrice Bellard and that’s enough for a few centuries 😅