This is a repo for recording my self-study path of creating a ray-tracing renderer from scratch.
Once you've cloned, the Visual Studio 2022 solution file is in the root named RayTracing.sln
. And all source code of the renderer is under RayTracing/src/
. However, the RayTracing/src/other
is where I did random tests for a better understanding(for exmaple reinventing some wheels); it's ugly now so consider not looking that.
For reference, I am following the book series Ray Tracing in One Weekend, The Next Week, and The Rest of Your Life on GitHub as well as the video series Ray Tracing, The Cherno on YouTube, and then the big guy Physically Based Rendering:From Theory To Implementation by Matt Pharr, Wenzel Jakob, and Greg Humphreys. Many thanks to these authors, I have already learned a lot even though I just started.
Video Series Ray Tracing, from The Cherno
Although called "from scratch", I use an app template from TheCherno/WalnutAppTemplate.git
to help me handle GUI and visualize the render output interactively. This helps me get rid of things that are not so important at this point and focus on the core parts.
- Add Opacity in the Material class, as a random scaler to decide whether the ray should reflect or refract
- Use incident direction, normal, and index of refraction(IOR) to calculate the refracted direction
- Refactor the Solve Quadratic function and its result struct for clarification
- When a ray hits, calculate whether it hits in the front face or the back face
The glass spheres still look odd when compared to a real-world one.
Ray.Tracing.2023-02-13.10-43-16.1.mp4
- Implement the Texture base class, and several child classes
- Implement the uv calculation when hit occurs
- Refactor the Material class and Renderer class to accept different textures
- Render an Earth sphere