Raytracing

Version 3 of 3

Four bounces.

GPU · GLSL · today

This version

Four spheres, a floor, shadow rays and four reflection bounces per pixel at full frame rate: what the CPU versions had to fake.

How this version works

This fragment shader renders at a configured scale of 0.6, tracing four orbiting, bobbing spheres and a checkerboard plane. A fixed loop processes up to four surface hits, accumulating lighting and updating a colour-tinted reflection weight at each hit. Shadow rays reduce diffuse lighting on both spheres and floor, and power-60 highlights sharpen the reflections' appearance. The fourth sphere has a reflection factor of 0.85, compared with 0.4 for the other spheres and 0.3 for the floor. Floor hits mix the accumulated colour towards a fog colour, and the final output receives a power-0.4545 gamma adjustment.

The trick in this version

A bounded GLSL loop replaces recursive calls, carrying the ray origin, direction and reflection weight between iterations. Small normal offsets reduce self-intersection, and all intersections are calculated in the fragment shader rather than through dedicated ray-tracing hardware.

Historical context · GPU

  1. 2018 · NVIDIA · RTX

    Hardware ray tracing

    Dedicated hardware for ray–triangle intersection finally made traced reflections and shadows a standard real-time feature.

Platform
GPU · GLSL
Era
GPU
Rendered on
GPU
Tags
Whitted · recursion
Sources
Hardware ray tracing (2018)