Skip to content

kitrofimov/srp

Repository files navigation

srp

(stands for software rendering pipeline)

Highly inspired by OpenGL API and made only for learning purposes, this is my first serious project in C (still 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!

This is a rendering pipeline written fully in software that uses only the CPU for computation. It 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

Read the documentation for master branch here, or build the documentation yourself (see Building section)

Building

git clone https://www.github.com/fahlerile/srp
mkdir srp/build
cd srp/build
cmake .. -D CMAKE_BUILD_TYPE=Release
make
cd bin

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

Similar/related projects

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.

References

And many, many more, all of which I will not find anymore...

TODO

Features

  • Add interpolation with perspective correction
  • Fix rasterization rules (see the gaps between triangles in 03_spinning_textured_cube example)
  • Implement other primitives (lines, points, lines/triangles strip/adjacency etc.)
  • Implement interpolation for types other than double (shouldn't it just be double and float?)
  • Add multisampling
  • Advanced texture techniques:
    • (Bi)linear filtering
    • Mipmapping
    • Anisotropic filtering
    • Transparent textures?

Optimization

  • Are vec and mat functions inlined by the compiler? Should they be? Are mat or vec ever passed by-value?
  • Use a profiler to find bottlenecks in frequently-used functions
  • Draw primitives in parallel (OpenMP)

What I learned

This is a section specially for my portfolio, so feel free to skip it. Well, I learned:

  • Some C programming techniques and library design
  • Importance of having a plan, an end goal:
    • This project started as something completely different from what it is now
  • Basic Git workflow
  • The importance of atomic (if it is possible) commits and meaningful commit names
  • Premature optimization and optimization without measuring really is the root of all evil
  • Importance of readable code and comments where they are needed