GPU ray tracing adds five programmable shader types to the graphics pipeline
GPU ray tracing (DXR/Vulkan Ray Tracing) extends the traditional vertex-rasterization-fragment pipeline with five new programmable stages: (1) Ray generation shader — launches rays (typically from the camera or from a fragment shader); (2) Intersection shader — tests a ray against a primitive, enabling non-triangle geometry; (3) Any-hit shader — called for every candidate hit, used for alpha testing and transparency; (4) Closest-hit shader (hit shader) — called for the final closest intersection, used for shading; (5) Miss shader — called when a ray hits nothing, used for skybox or ambient contribution. Results from hit/miss shaders return to the ray generation shader for further processing. Unlike rasterization where output goes directly to a render target, ray tracing returns colour data back to whatever launched the ray, enabling recursive rays for reflections and global illumination.
Examples
A reflection ray: generated in the ray generation shader → intersection tested → closest hit calls the material shader → result returned to the original fragment for compositing. An alpha test: any-hit shader checks alpha at each candidate hit and rejects transparent ones.
Assessment
List the five GPU ray tracing shader types in execution order for a primary ray. Describe what each shader is responsible for and name one practical use case.