Computer Graphics (rasterisation, ray tracing, WebGPU) Module 6
Triangles, depth and visibility: a software rasteriser interview questions
Interview questions on “Triangles, depth and visibility: a software rasteriser”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
What is an edge function, and how do three of them decide whether a pixel centre is inside a triangle?
Answered in the lesson Rasterising triangles with edge functions
-
Fresher to mid
What are the barycentric coordinates of a pixel in a triangle, and how does a rasteriser get them?
Answered in the lesson Barycentrics and perspective-correct interpolation
-
Fresher to mid
How does the z-buffer algorithm decide what is visible, and why can opaque triangles be drawn in any order?
Answered in the lesson Depth buffers, precision and z-fighting
-
Fresher to mid
What is the difference between object-space and image-space hidden-surface methods? Give an example of each.
Answered in the lesson Hidden-surface removal beyond the z-buffer
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
You are writing a CPU rasteriser for a 1920 × 1080 target that keeps 8 sub-pixel bits. How wide must the integers for its edge values be, how do you evaluate them across a row, and how would you skip whole 8 × 8 blocks of pixels that a triangle cannot touch?
- What it tests
- Fixed-point ranges and the width of a product, incremental evaluation of a linear function, and a conservative test of a block from the edge values at its corners.
- First step
- Bound the numbers first. With 8 sub-pixel bits, x reaches 1920 × 256 = 491,520, below 2^19, so a coordinate difference needs 20 bits with its sign, and an edge value, a difference of two products of such differences, about 40 bits. That rules out 32-bit integers: use 64-bit integers, or doubles, which are exact below 2^53.
- Follow-ups
-
- How many additions does a row of 1,000 pixels cost?
- Which corner of a block do you test for each edge?
- When can a whole block be filled without testing its pixels?
From the lesson Rasterising triangles with edge functions
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your CPU rasteriser's images match the GPU's except along some horizontal and vertical edges, where they differ by one row or one column of pixels, yet neither image has a gap or a pixel drawn twice. Explain what is going on, say whether either renderer is wrong, and make the image test reliable.
- What it tests
- Ties at pixel centres that lie exactly on an edge, the freedom WebGPU leaves there, consistent tie rules that differ, and an image test that avoids or masks such pixels.
- First step
- Look at the centres of the pixels that differ: each lies exactly on an edge, which happens when corners sit on pixel centres or an edge runs exactly through a row of them. Both renderers decide those ties consistently, so each tiles the mesh exactly, but by different rules; WebGPU leaves the choice undefined.
- Follow-ups
-
- Why does neither image show a seam?
- How do you change the test scenes so that the images agree?
- When must the CPU rasteriser match the GPU exactly?
From the lesson Rasterising triangles with edge functions
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 4 minutes
-
Mid to senior
A software renderer textures a large floor made of two triangles. When the camera looks along the floor, the checkerboard bends along the triangles' shared diagonal, and the checks slide about as the camera moves. Explain what is wrong, with numbers, and fix it.
- What it tests
- Affine against perspective-correct interpolation, the part each corner's w plays, the kink along a shared edge, and how the error grows with the ratio of the corners' depths.
- First step
- Check how the texture coordinates are blended. If the screen-space weights are used directly, each triangle maps the texture linearly, and the two linear maps agree only along the diagonal, which is where the checks bend. Then compare the corners' w: seen along its length, the floor's far corners are several times as deep as its near ones.
- Follow-ups
-
- How large is the error, and what makes it grow?
- Why do the checks slide when the camera moves?
- What must the rasteriser carry for each vertex, and when does it divide?
From the lesson Barycentrics and perspective-correct interpolation
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Choose a WGSL interpolation for each fragment input and defend it: a texture coordinate, a u32 material index, a world-space normal, a screen-space vignette coordinate and one colour per triangle for flat-shaded art. Which of them would you sample at the centroid under multisampling?
- What it tests
- What each of WGSL's interpolation types and sampling choices does, which inputs each one suits, and what the provoking vertex and centroid sampling change.
- First step
- Sort the inputs by what they belong to: the surface, the screen, or the triangle as a whole, and mark the ones that are integers. Then decide for each group whether its value should be blended at all, and whether it must stay inside its range at a triangle's edges.
- Follow-ups
-
- What goes wrong if the material index is passed as a float with the default interpolation?
- Which vertex does a flat input take its value from?
- What does centroid sampling cost?
From the lesson Barycentrics and perspective-correct interpolation
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Per-pixel lighting in a software renderer looks darker in the middle of a sphere's large triangles than at their corners, and the dark patches grow on coarser meshes. Explain with numbers and fix it; then say whether depth needs the same treatment.
- What it tests
- Interpolated unit vectors losing length and what that does to N · L, where the normalisation belongs, and how depth is interpolated compared with the values of a surface.
- First step
- Print the length of the interpolated normal at a pixel in the middle of a triangle and at one near a corner. A weighted sum of unit vectors is shorter than 1 unless they agree, and lighting multiplies by it, so compare N · L with and without normalising the blend at both pixels.
- Follow-ups
-
- Why do coarser meshes show it more?
- Would normalising the vertex normals fix it?
- Is depth blended the same way, and does it need correcting?
From the lesson Barycentrics and perspective-correct interpolation
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A game draws bullet-hole decals exactly on walls. Up close they look fine, but from 50 m away they flicker, and a quick fix that moved the near plane out cut off the player's own weapon. Explain both, and design a proper fix with WebGPU's settings.
- What it tests
- Coplanar z-fighting, why the near plane is the wrong tool for it, WebGPU's depthBias and depthBiasSlopeScale, and what a constant bias costs.
- First step
- Name the case: a decal lies exactly in its wall's plane, so the two depths are equal apart from rounding, and no amount of precision separates equal numbers. The fix must make the decal's depths differ from the wall's, which is what a depth bias on the decal's pipeline does.
- Follow-ups
-
- Which sign and size of bias, and why add the slope term?
- What does the bias cost, and where would players see it?
- Why did moving the near plane cut off the weapon?
From the lesson Depth buffers, precision and z-fighting
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
An open-world city uses a near plane of 0.1 m and a far plane of 10 km with 24-bit depth. Distant buildings flicker where facades meet signs and window frames. Size the problem with numbers and decide what to change.
- What it tests
- The gap between stored depths at a distance, how the near and far planes affect it, reversed-Z with a float format, and a decision backed by numbers.
- First step
- Work out how far apart two depths must be at a typical distance, say 2 km, for 24-bit storage to keep them apart, and compare that with the real gaps between the surfaces that flicker, a few centimetres at most.
- Follow-ups
-
- Would halving the far plane help?
- How far out would the near plane have to move?
- What does reversed-Z change, and on which formats?
From the lesson Depth buffers, precision and z-fighting
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A team switches its WebGPU renderer to reversed-Z, flipping the projection, the comparison and the clear value, yet distant z-fighting looks exactly as before. Explain why, prove it with a number, and say what they must check on other devices.
- What it tests
- Why reversed-Z gains only with float storage, unsigned normalised steps, the freedom WebGPU leaves depth24plus, and a test that proves the gain.
- First step
- Look at the depth format first. Reversed-Z helps through the way floating-point values are spaced, so check which format the depth buffer really has, on each device the renderer runs on.
- Follow-ups
-
- Why does a 24-bit buffer gain nothing?
- Why can depth24plus behave differently from one device to another?
- How would you test the gain automatically?
From the lesson Depth buffers, precision and z-fighting
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
After back-face culling is switched on for a whole forest scene, leaves vanish when seen from below, open crates show the background where their insides should be, and a mirrored copy of a statue looks inside out. Explain all three and fix them without switching culling off everywhere.
- What it tests
- When back-face culling is valid, double-sided and open geometry, how a mirror reverses winding, and setting culling per kind of surface.
- First step
- Ask which surfaces are closed. Culling is safe only for closed meshes whose triangles all wind one way. A leaf is a single quad seen from both sides, and a crate without a lid is open, so their back faces are meant to be seen and culling removes them.
- Follow-ups
-
- How much does culling save on the meshes that are closed?
- Why does the mirrored statue look inside out?
- How would you set this up in WebGPU, where culling is part of the pipeline?
From the lesson Hidden-surface removal beyond the z-buffer
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A building's glass panes are drawn after the opaque scene, sorted by their centres from far to near and blended. Where panes interleave, the wrong pane shows in front at some crossings, and the error jumps about as the camera moves. Explain with a concrete arrangement and propose fixes.
- What it tests
- The painter's algorithm and its failure on cycles and crossings, sorting by centres, cutting polygons, and per-pixel ways to blend transparent surfaces.
- First step
- Picture three long panes that each lie over the next, like three planks in a loop. Each must be drawn after the one it covers, and the three requirements form a cycle, so no order of whole panes is right: sorting can only choose which crossing goes wrong.
- Follow-ups
-
- Why does the error jump as the camera moves?
- Which pane would you cut, and where?
- What can be done per pixel instead of sorting?
From the lesson Hidden-surface removal beyond the z-buffer
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
An indoor level of 20,000 static polygons is seen by a freely moving camera. Would you build a BSP tree for it? Say what it costs to build and to walk, what order it gives, and how it works with a depth buffer and with moving characters.
- What it tests
- BSP construction and the cuts it makes, the back-to-front and front-to-back walks and their costs, and combining an object-space order with a depth buffer.
- First step
- Separate what changes from what does not. The level never moves, so a tree built once can give an order from every viewpoint; the characters move, so they need a method that does not depend on a prebuilt order.
- Follow-ups
-
- How many pieces might the cuts add, and what controls that?
- Which walk would you use with a depth buffer, and why?
- What happens when a door in the level opens?
From the lesson Hidden-surface removal beyond the z-buffer
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
All Computer Graphics (rasterisation, ray tracing, WebGPU) interview questions · The Computer Graphics (rasterisation, ray tracing, WebGPU) track