About
OpenGL real-time ray tracer using Compute Shaders. Based on the "Ray Tracing in One Weekend series".
OpenGL real-time ray tracer using Compute Shaders, touching post-processing.
OpenGL real-time ray tracer using Compute Shaders. Based on the "Ray Tracing in One Weekend series".
The process is simple: normalizing the y coordinate and interpolating between two colors. Checking if the rays hit the sphere and displaying the color. The resulting color is computed by picking a random point inside a unit radius sphere, whose normal starts from the initial ray hit point. This is done recursively until a ray doesn't hit anything or a maximum depth is reached.
For metallic surfaces, rays aren't randomly scattered. Luckily, GLSL has the
reflect() function, which returns the reflected ray. Randomizing the reflected
ray by choosing a random endpoint, as we did for the matte surface, gives rough (fuzzy) surfaces.
A ray is split into both a reflected one and a refracted one. Assuming that all rays are only refracted results in one outcome. Using Schlick's polynomial approximation, we can determine if rays must be reflected instead of refracted, producing the final result.
Adding a Cornell Box introduces more complexity into the scene. To make things more realistic, emissive materials are added for ceiling lights and spheres. Rays hitting an emissive surface won't scatter, so they retain their true albedo color output.
On the post-processing layer, HDR is applied, making the emissive material stand out more. Bloom is also added, which renders lights as blurred (using Gaussian Blur) and adds the result on top of the base color.