r/GraphicsProgramming
•
u/egehancry
•
Oct 01 '26
•
1
From Zero to Understanding Ray Tracing - Part 3 (reflections)
Thank you for your support! Part 3 is about reflections.
Let me know what you think!
I also share it in X: https://x.com/sinaatalay/status/2105545919915786280
6
u/thb22 Oct 01 '26
This is great. Keen to watch more if you make them.
Would love to see one about optimisations. Like what if a ray gets "stuck" reflecting back and forth between two reflective surfaces - is there a cut off?
Also, a deep dive on textures
3
u/egehancry Oct 01 '26
Thank you for the ideas!
Usually, people set a maximum number of reflections, maybe around 6–7. The effect on the final color gets smaller anyway, since each reflection has half the weight of the previous one.
1
4
u/Bmandk Oct 01 '26
I'd love to have this is an interactive simulation, where you can individually enable features and inspect how each ray gets calculated. That would be the cherry on top for this.
1
3
u/20260819 Oct 01 '26
i'm studying / learning raytracing. your illustration is great. i don't understand the averaging method. why are the colors have the weighting as 1/2 1/4 and 1/8?
1
u/egehancry Oct 01 '26
Hello! @phlooo explained it well below. It also works just like in the video, which is enough for making interesting pictures.
I gave more details about the mathematical rigor of the video here: https://www.reddit.com/r/GraphicsProgramming/comments/1wurqmt/comment/pd6bprx/
This illustration is not meant to give the exact mathematical equations you should use in your project. I purposely chose simple formulas so that the intuition is not buried under overwhelming mathematical details.
For more rigorous mathematical models of reflections and related effects, I would suggest referring to well-established textbooks.
My goal here is to teach the intuition, not to serve as a technical reference. I want this to be a reference for intuitively understanding what is going on.
4
u/20260819 Oct 01 '26
thanks. i'm studying raytracing and i wrote one for learning purpose. i'm particularly interested in moving the camera INSIDE a sphere...:) total internal refractions occur so there're some regions that rays can't escape and get no color
5
u/phlooo Oct 01 '26
The balls are not perfect mirrors here, they don't reflect all of the light. That's why they can still have an apparent colour. So the bounced light is < 1.0
In this particular example material they decided it would be 1/2 so at each bounce there's half of the light reflected and half absorbed by the surface
3
u/egehancry Oct 01 '26
This illustration is not meant to give the exact mathematical equations you should use in your project. I purposely chose simple formulas so that the intuition is not buried under overwhelming mathematical details.
For more rigorous mathematical models of reflections and related effects, I would suggest referring to well-established textbooks.
My goal here is to teach the intuition, not to serve as a technical reference. I want this to be a reference for intuitively understanding what is going on.
2
u/pierspad Oct 01 '26
I wonder why I watched this for free instead of having to pay for it. Very high quality, clear and also a nice progression.
Wonder if you would fancy to share a sort of "making of"
2
u/egehancry Oct 01 '26 edited Oct 01 '26
Thank you very much.
If you have a content idea that you want to put out into the world, you can actually now brute-force it with Claude Code or Codex. So "making of" is mostly brute-forcing AI to make my content ideas real.
2
2
2
u/le-throw-away-acct Oct 01 '26
Refractions will be a fun one to watch, there's a lot to cover with it. Soft-shadows and penumbra would be another fun one. Or dealing with roughness. Looking forward to more!
2
29
27
1
u/AlexDicy Oct 01 '26
This is nice but man, I guess good use of AI for learning? All the sounds effects gave me headache haha
1
1
1
u/HigherMathHelp Oct 02 '26
Thanks for sharing your work! Have you considered contributing these to Wikipedia articles? The style seems suitable. Visualizations designed to provide intuition, rather than encyclopedic breadth or precision are encouraged, as long as they aren't factually incorrect. So if you're comfortable using an open license, your visualizations could be used there with a few small tweaks:
You could output an open format like WebM, probably just by changing FFmpeg output parameters.
You might be asked to use the TimedText feature for prose (you may be able to generate it with Python from the workflow you described previously).
You might be able to keep the sound effects, as they can be considered an accessibility aid (they're muted by default). You might just make sure they're designed as semantic cues rather than game-like flash.
If you decide to simplify logic or calculations (e.g., in the halving rule you used for each bounce), you might just want to explicitly mark it as a simple case.
That's just a thought, since you've been incorporating feedback. This sort of thing could add a lot of value, and I figure not everyone is aware of what's allowed/encouraged on Wikipedia. But if you prefer video shorts with snazzier sound effects and a unique personality, those are totally valuable too, of course!
2
u/egehancry Oct 02 '26
Thank you very much for the information. I actually didn’t know much about how this works on Wikipedia.
I’m working full-time on a broader goal of explaining every technical subject on earth visually, across multiple languages, and eventually building full-length STEM courses, so that’s where my focus is right now.
I really appreciate you taking the time to explain the Wikipedia process and the specific changes that would be needed. Maybe someone else may make that contribution.
1
1
u/LeLishes Oct 02 '26
this is great! If you are comfortable with sharing, how do you make such videos?
1
u/egehancry Oct 03 '26
Of course. I ask Claude Code to make these videos using https://github.com/google/filament. For the sound effects, I ask it to synthesize them by combining sine waves with different frequencies and amplitudes.
Then I describe the content I want. It makes something, and we keep refining it until it’s ready.
1
u/zephyr707 Oct 03 '26
haha i love this, are the sound effects procedurally generated based on the animations or done in post? or is it just AI generated at the same time or analyzing the image/video?
2
u/egehancry Oct 03 '26
Sound effects are generated using sine functions with different amplitudes and frequencies, synthesized by AI to match the animations we’re showing.
3
2
2
2
u/alphapussycat Oct 02 '26
I mean no? This explained nothing. Only yoing children don't know about light bouncing. What the "zero" is is basically not knowing algorithms to find the polygon the ray intersects.
This is kind of a "infant to zero" explanation.
2
1
25
u/Klumaster Oct 01 '26
That part about averaging the ray bounces is misleading, each bounce should be multiplying by the surface reflectivity, not just arbitrarily halving.