Real-Time Rendering
How a frame gets drawn whatever the API: pipeline stages, shader programs, lighting, shadows, culling and GPU submission. Interviews probe this theory to see whether you could build a renderer.
on this pageshowhide
explore
- Graphics Pipeline6 questions
- Shader Programming Model6 questions
- Texturing and Surface Detail6 questions
- Lighting and Shading Models5 questions
- Physically Based Rendering5 questions
- Shadow Techniques6 questions
- Global Illumination and Reflections5 questions
- Culling, Occlusion and LOD6 questions
- Shading Architectures6 questions
- Transparency and Particles6 questions
- GPU Submission and Synchronization6 questions
- Anti-Aliasing and Post-Processing6 questions
- Real-Time Ray Tracing6 questions
questions
75 · 13 sectionsIn a rasterizing GPU pipeline, what stages does one triangle of a character mesh pass through from its vertex buffer to the pixels it covers?
basics
~20 sVertices are fetched and transformed by a vertex program, assembled into triangles, clipped, divided by w, mapped to the viewport and rasterized into fragments, which are depth-tested, shaded by a fragment program and blended into the colour target.
Why does a fragment program that writes its own depth or discards fragments weaken early depth testing, and how do you keep it working?
basics
~20 sEarly depth testing tests fragments before shading only when the result cannot differ. Program-written depth is unknown until the program runs and a discard leaves survival unknown, so the GPU tests or writes depth late and shades more hidden fragments.
In the graphics pipeline, why are triangles clipped in homogeneous clip space before the perspective divide, and what do the divide and viewport transform produce?
basics
~20 sClipping runs before the divide because a vertex behind the eye has w <= 0, and dividing by it flips or explodes the position. The divide yields normalized device coordinates; the viewport transform maps them to pixel positions and stored depth.
How does a GPU rasterizer decide which pixels a triangle covers, and why does it need a fill rule for edges shared by two triangles?
basics
~20 sThe rasterizer evaluates three edge functions at each sample position, usually the pixel centre, and covers the sample when all agree it is inside. A top-left fill rule gives samples lying exactly on a shared edge to one triangle only.
How does the stencil test work, and how would you use it to draw a mirror's reflection only inside the mirror's frame?
basics
~20 sThe stencil test compares a per-pixel integer, stored beside depth, against a reference value and updates it by rules for fail, depth-fail and pass. Draw the mirror to write 1, then draw the reflected scene only where stencil equals 1.
In a rasterizing GPU pipeline, how often do vertex, fragment and compute programs run, and what data does each one receive?
basics
~20 sA vertex program runs about once per vertex, a fragment program about once per covered pixel, and a compute program once per thread of its dispatch. Fragments receive vertex outputs interpolated across the triangle, plus per-draw constants and resource reads.
Why can a fragment-program branch on a per-pixel material flag run slower on some screen tiles than on others?
basics
~20 sGPUs run fragments in SIMD groups, typically 32 or 64 lanes sharing one instruction stream. When a group's pixels disagree on the flag, it executes both paths with lanes masked off, so tiles where materials mix pay for both.
What is opaque overdraw when a crowd of characters is drawn in arbitrary order, and when does a depth pre-pass pay off?
basics
~20 sOverdraw is shading a pixel more than once because nearer surfaces drawn later cover earlier ones. A depth pre-pass writes depth first so the colour pass shades each visible pixel about once; it pays when fragment cost outweighs drawing geometry twice.
Why do GPUs shade pixels in 2x2 quads, and how does that cause wrong-mip seams when a texture is sampled inside a divergent branch?
basics
~20 sGPUs shade 2x2 quads so derivatives come from differencing neighbouring lanes, and texture sampling uses them to pick a mip. Inside a divergent branch a neighbour may skip the code, the derivative is undefined, and wrong-mip seams appear.
How can register pressure lower occupancy and slow a texture-heavy fragment program after an edit that barely changes its instruction count?
basics
~20 sEach GPU processor has a fixed register file shared by its resident SIMD groups. A program needing more registers per lane fits fewer groups, so fewer are ready to run while others wait on texture reads, and memory latency stops being hidden.
What is a mipmap chain, why do textured surfaces far from the camera need one, and what does it cost in memory?
basics
~20 sA mipmap chain stores a texture with successively halved, prefiltered copies down to 1x1. Distant surfaces sample the level whose texels match the pixel size, which suppresses shimmer and moire for about one third more memory.
How do bilinear, trilinear and anisotropic texture filtering differ, and which artefact on a tiled stone floor does each one fix?
basics
~20 sBilinear blends the four nearest texels within one mip level; trilinear also blends two adjacent levels, removing visible mip bands; anisotropic takes several probes along a stretched footprint, so grazing-angle floors stay sharp instead of smearing.
Why are colour textures stored sRGB-encoded while normal, roughness and other data maps stay linear, and what breaks when they are swapped?
basics
~20 ssRGB encoding gives dark tones more of the 8-bit codes, and the GPU decodes it to linear on sampling. Data maps hold numbers, not colours: decoding them tilts normals and lowers roughness, so surfaces look skewed and glossier.
How does a tangent-space normal map fake surface detail, what is the TBN basis, and why do mismatched tangents cause lighting seams?
basics
~20 sA tangent-space normal map stores per-texel normals in the surface's local frame: tangent along u, bitangent along v, normal outward. The TBN basis rotates them to world space; baker and renderer tangents that differ break lighting at seams.
A UI texture atlas shows neighbouring icons bleeding into each other's edges when drawn small; what causes it, and how do you fix it?
basics
~20 sFiltering reaches past each icon: bilinear taps near an edge pull in neighbours, and coarser mip levels average across icon borders. Pad icons with duplicated edge texels, align them to a power-of-two grid, and cap the mip level the padding protects.
In a classic local lighting model, what do the ambient, Lambert diffuse and specular terms each add, and why is dot(N, L) clamped at zero?
basics
~20 sAmbient adds a constant stand-in for bounced light, Lambert diffuse scales each light by dot(N, L), the cosine between normal and light direction, and specular adds a view-dependent highlight. Clamping at zero stops back-facing light subtracting.
How does Blinn-Phong's half vector replace Phong's reflection vector, and what does the specular exponent do to the highlight?
basics
~20 sPhong compares the view direction with the light mirrored about the normal; Blinn-Phong compares the normal with H = normalize(L + V). Both raise that cosine to an exponent: higher exponents give smaller, tighter highlights with the same peak.
In a torch-lit stone corridor, how do point, spot and directional lights differ, and why window a point light's inverse-square falloff to a finite range?
basics
~20 sDirectional lights have a direction and no falloff, point lights radiate from a position with inverse-square falloff, and spot lights add a cone. Windowing that falloff to zero at a range lets distant surfaces skip the light without a visible edge.
Why does a low-polygon sphere's highlight look faceted or jump between vertices, and how do flat, Gouraud and per-fragment shading differ?
basics
~20 sFlat shading lights each triangle once, Gouraud lights each vertex and interpolates the colour, and per-fragment shading interpolates normals and lights every pixel. Gouraud misses or smears highlights that peak between vertices; per-fragment shading keeps them.
A stone corridor's torches are baked into lightmaps, but designers now want torches that flicker and can be put out while characters walk past; what do you bake and what stays dynamic?
basics
~20 sKeep static geometry's bounced light baked, and either bake each torch into its own scalable lightmap layer, since light adds linearly, or light the torches dynamically. Characters need dynamic direct light and shadows; lightmaps only cover static geometry.
In a PBR metallic-roughness material, what do the base colour, metallic and roughness parameters each control?
basics
~20 sBase colour is diffuse albedo for non-metals and specular reflectance (F0) for metals; metallic chooses between those two meanings; roughness sets how widely microfacet normals spread, from a sharp mirror highlight to a broad, dim one.
What are the terms of the Cook-Torrance microfacet specular BRDF, and what physical effect does each one model?
basics
~20 sCook-Torrance specular is D·F·G / (4·dot(n,l)·dot(n,v)): D is the density of microfacets facing the half vector, F how much each reflects at that angle, G the share neither shadowed nor masked, and the denominator maps facet terms back to the macro surface.
What does Schlick's Fresnel approximation compute in a PBR shader, and why is F0 near 0.04 for dielectrics but coloured for metals?
basics
~20 sSchlick's approximation gives reflectance as F0 + (1 - F0)(1 - cos theta)^5, rising from F0 head-on to 1 at grazing. Dielectrics reflect about 2-5% head-on, set by refractive index; metals reflect far more and unequally per wavelength, so their F0 is a colour.
How does the split-sum approximation make image-based specular lighting from one environment map cheap enough for real time, and what does it get wrong?
basics
~20 sIt splits the specular lighting integral into two precomputed factors: an environment map prefiltered with the GGX lobe into roughness-indexed mips, and a 2D table over dot(n, v) and roughness that scales and biases F0. Assuming view equals normal loses stretched grazing reflections.
In a microfacet PBR shader, an artist's rough gold material goes dark at grazing angles; how do you find out whether the BRDF is losing energy, and fix it?
basics
~20 sRun a white furnace test: spheres with F0 = 1 under uniform white light should vanish. Single-scattering GGX darkens rough spheres, worst at grazing, because Smith masking discards light that would bounce again; a multiple-scattering compensation factor restores it.
How does shadow mapping decide whether a pixel is in shadow, from rendering depth from the light to the per-pixel comparison?
basics
~20 sShadow mapping first renders depth from the light into a texture. When shading, each pixel's point is projected into the light's view and its depth compared with the stored depth; if it is farther, something blocks the light.
In shadow mapping, what causes shadow acne and peter-panning, and how do constant bias, slope-scaled bias and normal offset trade between them?
basics
~20 sAcne is false self-shadowing: a shadow texel covers a sloped surface patch whose depth varies, so part of it tests behind its own stored depth. Bias hides that error; too much bias detaches shadows from their casters, called peter-panning.
How do percentage-closer filtering (PCF) and PCSS soften shadow-map edges, and why are a shadow map's comparisons filtered rather than its depths?
basics
~20 sPCF compares the receiver against several nearby shadow-map texels and averages the pass-or-fail results, giving a fixed-width soft edge. PCSS first averages nearby blocker depths to size the penumbra, then scales the PCF kernel to match. Averaged depths would mean nothing.
In a sunlit open landscape, cascaded shadow map edges crawl and flicker whenever the camera turns or moves; what causes it, and how do you split, fit and stabilize the cascades?
basics
~20 sEach cascade is refit to its frustum slice every frame: camera turns change its size and moves slide its texel grid by sub-texel amounts, so edges resample and crawl. Fit a fixed-size bounding sphere and snap its origin to whole texels.
How do stencil shadow volumes mark shadowed pixels, and why did shadow mapping replace them in most real-time renderers?
basics
~20 sEach caster's silhouette is extruded away from the light into a volume; drawing its faces into the stencil buffer counts the volumes each visible point lies inside, and a nonzero count means shadow. Edges are exact, but fill rate is heavy.
How do screen-space reflections find what a polished floor reflects, and what can they never show without a fallback?
basics
~20 sScreen-space reflections march the reflected ray across the depth buffer and reuse the lit colour where it hits. They cannot show what is off screen, hidden behind nearer objects or facing away from the camera, so misses fall back to reflection probes.
What does an irradiance light probe store, and how does a moving character use nearby probes to pick up bounced light?
basics
~20 sAn irradiance light probe stores incoming light at one point from all directions, compressed into a few spherical-harmonic coefficients per colour. A moving object blends nearby probes and evaluates the blend at each surface normal for diffuse bounced light.
Why do reflections from a cubemap reflection probe slide across a polished floor as the camera moves, and how does box parallax correction fix it?
basics
~20 sA cubemap reflection probe is read by direction alone, as if its contents were infinitely distant, so reflections of nearby walls drift with the viewer. Box parallax correction hits the reflected ray against a room-sized box and reads toward that point.
Why do irradiance probes leak courtyard sunlight onto a character just inside a dim timber hall, and how do you stop it?
basics
~20 sProbe interpolation weights neighbours by position alone, so with a wall thinner than the probe spacing, sunlit outdoor probes still light points inside. Per-probe visibility, back-face weights with a normal bias, relocating buried probes and per-room volumes largely stop it.
How would you choose how a game's indirect light is produced (baked, run-time probe updates, screen-space or voxel GI) when it has a day-night cycle and destructible buildings?
basics
~20 sStart from what changes: static light and geometry can be baked cheaply, a moving sun needs relightable or run-time-updated probes, and destruction favours run-time probes, voxel GI or a screen-space layer. Then fit per-tier budgets, memory, leak risk and bake iteration time.
In a real-time renderer, what do frustum culling, backface culling and occlusion culling each remove, and why are all three needed?
basics
~20 sFrustum culling drops whole objects outside the camera's view volume, backface culling drops triangles facing away from the camera, and occlusion culling drops objects hidden behind nearer geometry. Each removes work the other two cannot.
How should a renderer choose a mesh's level of detail, and how do you stop trees from visibly popping as the player walks toward them?
basics
~20 sChoose the coarsest level whose geometric error, projected to pixels, stays under a threshold, so field of view and resolution count. Hysteresis stops flip-flopping, dithered cross-fades hide the switch, and impostors replace the farthest trees.
How does a bounding-volume hierarchy speed up frustum culling of a city with tens of thousands of buildings, and when is a flat array faster?
basics
~20 sA hierarchy tests a node's bounds once: outside rejects the whole subtree, fully inside accepts it with no further tests, and only straddling nodes recurse with the planes they still cross. A flat SIMD array often wins for moving objects.
In GPU-driven rendering, how does a compute pass cull tens of thousands of instances and compact the survivors, and what does moving culling off the CPU cost you?
basics
~20 sA compute pass runs one thread per instance, tests its bounds against the frustum and a depth pyramid, and appends survivors to dense per-draw lists through atomic counters. The CPU loses same-frame knowledge of visibility and debugging gets harder.
How does Hi-Z occlusion culling test an object's bounds against a depth pyramid, and why do many renderers draw last frame's visible objects before building it?
basics
~20 sHi-Z culling builds a mip chain of depth keeping each region's farthest value, then rejects an object whose nearest depth is behind it. Drawing last frame's visible set first gives a current pyramid without stale-depth false culls.
In deferred shading, what is a G-buffer, what does it typically store per pixel, and why is it filled before any lighting runs?
basics
~20 sA G-buffer is a set of screen-sized render targets that a deferred renderer's geometry pass fills with each visible pixel's surface attributes: depth, base colour, normal and material parameters. Lighting then reads them, so lights touch only visible surfaces.
Why does classic forward shading's cost grow with lights times objects, and how does deferred shading change that cost for scenes with many dynamic lights?
basics
~20 sClassic forward shading lights each object while drawing it, so every fragment evaluates every light assigned to its object, hidden fragments included. Deferred shading writes surface attributes once, then applies each light only to the screen pixels it covers.
Why does deferred shading handle transparent surfaces and MSAA poorly, and how does a deferred renderer still draw glass and anti-aliased edges?
basics
~20 sA G-buffer stores one surface per pixel, so glass and the surface behind it cannot both be lit from it; deferred frames add a forward pass for transparents. MSAA multiplies G-buffer memory by the sample count and needs per-sample lighting at edges.
On bandwidth-limited hardware, how do you estimate a deferred renderer's G-buffer memory traffic per frame at a given resolution, and how do you cut it?
basics
~20 sMultiply bytes per pixel by pixel count, then count each write and read: geometry-pass writes, lighting reads, lit-target writes and per-light re-reads in classic deferred. Cut it with packed channels, position from depth, tiled lighting and on-chip G-buffers on tile-based GPUs.
How does Forward+ build per-tile light lists for a night market lit by hundreds of small lights, and why does clustered shading also slice in depth?
basics
~20 sForward+ splits the screen into tiles, takes each tile's depth range from a depth pre-pass, and keeps only lights whose bounds meet that tile's frustum. Clustered shading also slices depth, so one foreground edge cannot pull in every light behind it.
Why do renderers draw transparent surfaces after all opaque ones, sorted back to front, with depth testing on but depth writes off?
basics
~20 sBlending mixes each surface with the colour already drawn, and over depends on order. So opaque geometry goes first, transparent surfaces follow back to front, the depth test hides glass behind walls, and no depth writes keeps transparent surfaces from rejecting each other.
How does a GPU particle system emit, age, move and kill particles each frame and keep a compact list of the living without CPU readback?
basics
~20 sGPU particles live in a fixed pool with a stack of free slots and alive index lists. Passes pop slots to emit, age and move particles, free the expired, and append survivors to a new list whose atomic count drives an indirect draw.
What is premultiplied alpha, and why does it remove dark fringes from filtered sprites and let one blend mode mix additive and alpha-blended particles?
basics
~20 sPremultiplied alpha stores colour already multiplied by alpha, so transparent texels are zero and add nothing when filtered. The blend becomes C = Cs + (1 - As) * Cd, which is additive when alpha is zero, so one blend state covers both.
Glass panes in a greenhouse intersect, and seen from inside they blend in the wrong order even when sorted per object; why, and what do order-independent transparency techniques trade to fix it?
basics
~20 sPer-object sorting picks one order for a whole mesh, but intersecting panes are each in front on different pixels, so no object order is right. Order-independent transparency resolves order per pixel: depth peeling costs passes, per-pixel lists cost memory, weighted blending approximates.
A smoky explosion of thousands of particles costs several milliseconds of GPU time when the camera is inside it and shows hard lines where puffs meet the ground; why, and how do you fix both?
basics
~20 sInside the cloud each billboard covers much of the screen, so every pixel blends dozens of layers: overdraw sets the cost. Render particles at reduced resolution, trim quads, fade near the camera. Soft particles fade alpha against scene depth, removing the hard lines.
How do GPU command buffers let several CPU threads record one frame's draws, and how is the recorded work ordered at submission?
basics
~20 sA command buffer is a list of GPU commands the CPU records for later execution. Each thread records its own buffers from its own command memory, and one submission hands them to a queue in the order the frame needs.
How do fences let the CPU record two or three frames ahead of the GPU, and what breaks when a per-frame buffer is reused early?
basics
~20 sThe GPU signals a fence when a frame's work completes. Each frame in flight has its own buffers; before reusing a set, the CPU waits on the fence of the frame that last used it, or overwrites data the GPU still reads.
Why do per-draw state changes and resource binding cost CPU time in a renderer, and what does pre-built pipeline state remove?
basics
~20 sDriver-managed APIs validated and translated each state change at draw time, sometimes recompiling shaders. A pre-built pipeline state object bakes shaders and fixed-function state into one validated object at load, so a draw just switches to it.
A post-processing pass reads stale or half-written data from the colour target the previous pass rendered, but only on some GPUs; what barrier is missing, and how do you place barriers without stalling the GPU?
basics
~20 sA barrier from colour-target write to shader read is missing; it orders the passes, makes the writes visible to texture reads and transitions the target's layout. Batch transitions per pass boundary and narrow their stages so the GPU drains once.
An open-world game hitches whenever streamed meshes and textures are copied to the GPU; how would you redesign the upload path, its heap types and its residency handling?
basics
~20 sSub-allocate from large pre-made heaps, stage data through a mapped upload ring, copy on a separate queue into device-local memory, and gate use and reuse with fences. Cap bytes per frame and evict least-recently-used data under the budget.
How does MSAA differ from supersampling in what it samples, shades and stores, and which aliasing does it leave untouched?
basics
~20 sSupersampling shades every sample, multiplying shading cost. MSAA tests coverage and depth at several samples per pixel but shades once per pixel per triangle, then averages them: geometric edges smooth, while shader and alpha-test aliasing remain.
How does temporal anti-aliasing accumulate samples across frames, and why do thin railings leave ghost trails during a fast camera pan?
basics
~20 sTAA jitters the projection by a sub-pixel offset each frame, reprojects the accumulated history with motion vectors and blends in a little of the new frame. Ghosts appear when history no longer matches the surface: disocclusion, wrong motion vectors, weak rejection.
Why does a renderer light the scene in linear HDR and tone map it, instead of clamping each pixel to the display range?
basics
~20 sReal light spans far more range than a display, so lighting is computed in linear floating point, then exposed and tone mapped by a curve that compresses highlights smoothly. Clamping instead turns bright skies flat white and shifts their hue.
How does screen-space ambient occlusion estimate occlusion from the depth buffer, and why does it need per-pixel noise and a blur?
basics
~20 sSSAO places a few points in a hemisphere around each pixel's surface, projects them and counts how many lie behind the depth buffer. Few samples band, so tiled noise rotates the kernel per pixel and a depth-aware blur removes the noise.
After a renderer swaps its own TAA for a temporal upscaler at a lower internal resolution, textures blur and particles smear; which inputs did it get wrong?
basics
~20 sA temporal upscaler is TAA that reconstructs a larger output, so it needs correct jitter, depth, motion vectors and exposure. Blurry textures mean no negative mip bias for the lower internal resolution; smearing particles mean missing motion vectors or reactive mask.
Why does a real-time ray tracer need a bounding volume hierarchy, and how does a ray traverse one to find its closest hit?
basics
~20 sA bounding volume hierarchy nests boxes around groups of triangles so a ray tests a few boxes instead of every triangle. Traversal enters only boxes the ray hits, nearest first, and skips boxes beginning beyond the closest hit so far.
Why do real-time ray tracers split the scene into bottom-level and top-level acceleration structures, and what does each level hold?
basics
~20 sA bottom-level structure holds one mesh's triangles in object space; a top-level structure holds instances, each a transform pointing at a bottom-level structure. Moving objects then rebuild only the small top level, and repeated meshes share one bottom level.
In a ray-tracing pipeline, what do the ray-generation, closest-hit, any-hit and miss programs each do, and why does alpha-tested foliage need any-hit?
basics
~20 sRay generation launches rays per pixel and writes results; closest-hit shades the nearest accepted hit; miss runs when nothing is hit; any-hit runs on candidate hits and can reject them. Foliage needs any-hit to ignore hits where its alpha texture is transparent.
Why do hybrid renderers trace about one reflection ray per pixel on rain-wet streets, and how does spatiotemporal denoising make that noisy result usable?
basics
~20 sA frame can rarely afford more than one ray per pixel per effect, so each pixel gets one noisy Monte Carlo sample. A denoiser reprojects and accumulates samples over frames, then blurs spatially with edge-stopping weights guided by an estimated per-pixel variance.
In a scene with destructible, deforming meshes, when do you refit a bottom-level acceleration structure instead of rebuilding it, and what quality does a refit lose?
basics
~20 sRefit when a mesh keeps its triangle list and deforms modestly, like a skinned character: recomputing boxes bottom-up is cheap but keeps the old grouping, so boxes bloat and overlap. Rebuild when topology changes or that bloat makes traces too slow.