chuigda / softpipe

A very toy software renderer written in python, MATLAB and C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

softpipe

A very simple, proof of concept software rasterizer.

⚠️⚠️⚠️WARNING⚠️⚠️⚠️

This piece of code is just a proof-of-concept, showing how rasterization-based rendering works. The code quality (especially the MATLAB part) is not very good, and both versions are very slow (takes >1 seconds to render a 600 * 600 triangle, thus 180,000 pixels). For production purpose you may want llvmpipe things instead.

Overall workflow

  • Run vertex shader on all input vertices

  • Set the 4th dimension of all output `v_position`s to 1

  • For each 3 vertex outputs, scan through the rectangle containing this triangle

    • Interpolate outputs with barycentric coordinate

    • Do depth test

    • Run fragment shader on interpolated output, get the final fragment color

About

A very toy software renderer written in python, MATLAB and C

License:GNU Affero General Public License v3.0


Languages

Language:Python 67.4%Language:MATLAB 16.2%Language:C 15.3%Language:M 1.1%