Skip to content
CoreSource checked

Scanline Rendering

Renders polygons row by row across the image.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Intermediate
Family
Raster Rendering
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
3
Code example
Not ready
Visualization
Ready

Overview

Scanline Rendering processes horizontal lines of pixels, finding polygon spans that cover each row.

Core Concepts

rendered imagevisibility orderingraster renderingscene representationvisibility testpixel output

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(p + e)

Average

O(p + e)

Worst

O(p + e)

Space

O(e)

When to Use

  • Use Scanline Rendering when you need to walks across image rows.
  • Use it for software rasterizers with inputs like polygons.
  • Use it when the scene representation and quality target match the rendering tradeoff.
  • Use it when the Raster Rendering tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when the cost per pixel or sample is too high for the desired frame rate.
  • Avoid it when the required output is not rendered pixel buffer.

What It Does

  • Walks across image rows
  • Fills visible spans between polygon edges

Use Cases

  • Software rasterizers
  • 2D polygon filling
  • Classic rendering pipelines

Inputs

  • Polygons
  • Image dimensions

Outputs

  • Rendered pixel buffer

Key Formulas (1)

Edge intersection

x = x1 + (y − y1) · (x2 − x1) / (y2 − y1)
x = x1 + (y - y1) * (x2 - x1) / (y2 - y1)

Finds where a polygon edge crosses the current scanline.

Pseudocode

  1. 1.Build an edge table
  2. 2.Move scanline from top to bottom
  3. 3.Track active polygon edges
  4. 4.Fill spans between edge pairs
  5. 5.Update active edges for the next row

Canonical Example

Input
scene = one triangle, one camera, one light
Output
image pixels showing the visible triangle
Explanation
Scanline Rendering: The algorithm converts scene data into visible pixel results.

Implementation Notes

  • Keep the input contract explicit: Polygons; Image dimensions.
  • Use this step as the implementation spine: Build an edge table.
  • Then preserve the next state change: Move scanline from top to bottom.
  • Build tiny scenes with known geometry before testing complex materials or lighting.

Common Pitfalls

  • Scanline methods are efficient for polygon filling and classic software renderers.
  • Ignoring coordinate spaces, depth precision, or sampling noise while debugging image artifacts.
  • Returning rendered pixel buffer without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show horizontal rows filling polygon spans.

Scanline Rendering mechanism walkthrough step 1 of 5
Step 1 of 5: Build an edge table
scanline-spans

Notes

Scanline Rendering operates in O(p + e) time and O(e) space within the Raster Rendering family. Key governing relation: x = x1 + (y - y1) * (x2 - x1) / (y2 - y1). Often compared with Rasterization and Z-Buffering.

Sources (1)

What each reference supports for this entry.

Real-Time Rendering

Book

Computer graphics reference for raster pipelines, shading, antialiasing, texture filtering, and real-time rendering techniques.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Variant ofRasterization

Scanline rendering rasterizes primitives row by row.

Scanline renderers can use depth buffering for visible surface selection.

Related Algorithms

Tags

GraphicsVisibilityClassic