Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

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.

15 questions: 4 warm-ups and 11 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. 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

  2. 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

  3. 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

  4. 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.

  1. 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

    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.

    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
  2. 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

    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
  3. 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

    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
  4. 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

    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
  5. 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

    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
  6. 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

    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
  7. 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

    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
  8. 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

    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
  9. 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

    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
  10. 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

    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
  11. 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

    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

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.