A software rendering pipeline using only CPU computation that features:
- Fully programmable vertex and fragment shaders
- A small math library with vector and matrix structures to use in shader programming
- Texture mapping
- Shader uniforms
- Affine attribute interpolation
Highly inspired by OpenGL API and made mostly for learning purposes, this is my first serious project in C (WIP at the moment) and my first project in the field of computer graphics. The only dependency is stb_image.
You probably do not want to use this in production code! If you need to, see this awesome project.
Read the documentation for master branch here, or build the documentation yourself (see Building)
- Create a general-purpose rendering library (primary use case: CPU-only devices)
- Apply the fundamentals of software design patterns to a real-world case
- Learn basics of computer graphics
- Learn C programming language thoroughly & acquire experience working with it
- Advanced C programming techniques, library design
- Importance of having a plan & an end goal (this project started as something completely different from what it is now)
- Git workflow (+ the importance of atomic commits and meaningful commit names)
- Premature optimization really is the root of all evil
- Importance of writing clean code & adding comments
git clone https://www.github.com/fahlerile/srp
mkdir srp/build
cd srp/build
cmake .. -D CMAKE_BUILD_TYPE=Release
make
cd binYou can also build the examples with -D BUILD_EXAMPLES=1 and the documentation with -D BUILD_DOCS=1 arguments passed to cmake. Building the documentation requires having dot binary in PATH.
- https://github.com/rswinkle/PortableGL
- https://github.com/NotCamelCase/SoftLit
- https://github.com/nikolausrauch/software-rasterizer
- https://github.com/niepp/srpbr
And a lot more... Here I mentioned only those projects on which I looked at as a reference while making this one. If you need more similar projects, see this and this.
- General Computer Graphics concepts:
- Triangle rasteization:
- Perspective-correct interpolation:
And many, many more, all of which I will not find anymore...
- Add interpolation with perspective correction
- Fix rasterization rules (see the gaps between triangles in
03_spinning_textured_cubeexample) - Implement other primitives (lines, points, lines/triangles strip/adjacency etc.)
- Implement interpolation for types other than
double(shouldn't it just bedoubleandfloat?) - Add multisampling
- Advanced texture techniques:
- (Bi)linear filtering
- Mipmapping
- Anisotropic filtering
- Transparent textures?
- Are
vecandmatfunctions inlined by the compiler? Should they be? Arematorvecever passed by-value? - Use a profiler to find bottlenecks in frequently-used functions
- Draw primitives in parallel (OpenMP)