Files
software_rasterizer/README.md
2022-02-26 11:23:57 +01:00

4.3 KiB

Things to do:

  • Drawing triangles

  • Drawing cubes and lines for testing

  • Y up coordinate system, left handed

  • Drawing a cube with perspective

  • Culling triangles facing away from camera

  • Texture mapping

  • Basic linear transformations - rotation, translation, scaling

  • Bilinear filtering of textures

  • Nearest filtering

  • Fix the gaps between triangles (it also improved look of triangle edges)

  • Perspective matrix vs simple perspective

  • Perspective correct interpolation

  • Depth buffer

  • Gamma correct blending - converting to almost linear space

  • Alpha blending

  • Premultiplied alpha

  • Merge with base

  • Lightning

    • GLOBAL Ilumination
  • LookAt Camera

  • FPS Camera

  • Reading OBJ models

  • Reading more OBJ formats

  • Reading OBJ .mtl files

  • Reading complex obj models (sponza)

  • Reading PMX files

  • Rendering multiple objects, queue renderer

    • Simple function to render a mesh
  • Clipping

    • Triagnle rectangle bound clipping
    • A way of culling Z out triangles
      • Simple test z clipping
      • Maybe should clip a triangle on znear zfar plane?
      • Maybe should clip out triangles that are fully z out before draw_triangle
  • Subpixel precision of triangle edges

  • Simple profiling tooling

  • Statistics based on profiler data, distribution information

  • Find cool profilers - ExtraSleepy, Vtune

  • Optimizations

    • Inline edge function
    • Expand edge functions to more optimized version
    • Test 4x2 bitmap layout?
    • Edge function to integer
    • Use integer bit operations to figure out if plus. (edge1|edge2|edge3)>=0
    • SIMD
    • Multithreading
  • Text rendering

  • Basic UI

  • Gamma correct and alpha blending

Clipping

There are 3 clipping stages, 2 clipping stages in 3D space against zfar and znear and 1 clipping stage in 2D against left, bottom, right, top(2D image bounds).

First the triangles get clipped against the zfar plane, if a triangle has even one vertex outside the clipping region, the entire triangle gets cut. So far I didn't have problems with that. It simplifies the computations and splitting triangles on zfar seems like a waste of power.

The second clipping stage is znear plane. Triangles get fully and nicely clipped against znear. Every time a triangle gets partially outside the clipping region it gets cut to the znear and either one or two new triangles get derived from the old one.

Last clipping stage is performed in the 2D image space. Every triangle has a corresponding AABB box. In this box every pixel gets tested to see if it's in the triangle. In this clipping stage the box is clipped to the image metrics - 0, 0, width, height.

Resources that helped me build the rasterizer (Might be helpful to you too):

To read