Coding Adventure: Ray-Tracing Glass and Caustics
Let's do some more ray-tracer coding and see if we can get it to render glass, and rainbows, and more! Support my work (and get early access to new videos and source code) on Patreon or Nebula * Patreon: https://www.patreon.com/SebastianLague * Nebula: https://go.nebula.tv/sebastianlague Source code: https://github.com/SebLague/Ray-Tracing Credits: * Music: https://github.com/SebLague/Misc-Project-Info/blob/main/Coding-Adventures/GlassAndCaustics.txt * Frosted glass reference: https://youtu.be/fWAAOWTV1K0?si=KL-EnzSZ6mLVfuqn Chapters: 00:00 Intro 02:02 Glass 04:58 Glass Bugs 09:04 NaNs 11:51 Absorption 13:49 Frosted Glass 15:44 Glass Ball Test 21:14 Stack versus Stoch 22:55 Visualizing Caustics 25:42 Cardioid Caustic 27:04 Water Caustic 32:24 Rainbow 36:01 Spectral Experiment 40:46 Outro
Video Chapters
- 0:00 Embark on a new coding adventure: mastering glass and caustics in ray tracing.
- 1:10 Behold, the `CalculateReflectionAndRefraction` function, splitting light into multiple paths.
- 2:10 HLSL limitations: recursion is out, so we're bringing back our trusty stack-based solution.
- 6:00 Seeing clearly now: Fixed normals allow light to finally pass through the glass correctly.
- 8:30 Final glass render: Two majestic glass dragons now reside peacefully in their Cornell box.
- 9:15 Nan-tastic: Mysterious speckles caused by "Not a Number" values from naughty math.
- 13:10 Frosted glass effect: Randomizing light directions creates a beautifully diffused, cloudy look.
- 16:20 Physical vs digital: Comparing the 3D print in the physical box to the rendered version.
- 20:40 Caustic patterns: Light focused by glass spheres creates beautiful, bright patterns on surfaces.
- 24:10 Final render: Color dragons bask under a stunning, full-spectrum rainbow.
Original Output
0:00 Embark on a new coding adventure: mastering glass and caustics in ray tracing. 1:10 Behold, the `CalculateReflectionAndRefraction` function, splitting light into multiple paths. 2:10 HLSL limitations: recursion is out, so we're bringing back our trusty stack-based solution. 6:00 Seeing clearly now: Fixed normals allow light to finally pass through the glass correctly. 8:30 Final glass render: Two majestic glass dragons now reside peacefully in their Cornell box. 9:15 Nan-tastic: Mysterious speckles caused by "Not a Number" values from naughty math. 13:10 Frosted glass effect: Randomizing light directions creates a beautifully diffused, cloudy look. 16:20 Physical vs digital: Comparing the 3D print in the physical box to the rendered version. 20:40 Caustic patterns: Light focused by glass spheres creates beautiful, bright patterns on surfaces. 24:10 Final render: Color dragons bask under a stunning, full-spectrum rainbow. Timestamps by McCoder Douglas