Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software Rasterizer

This is an experimental software rasterizer using traditional vertex interpolation with barycentric coordinates. The interface to this library uses variadic templates of tuples to allow for arbitrary numbers of attributes to be interpolated.

Usage

The main interface to this libary is the Pipeline Class, which is templated with the attributes of the shader to be used.

A pipeline allows a custom Shader to be supplied, consisting of a vertex and pixel / fragment stage. The number and type of attributes is mostly arbitrary, they must however implement the necessary operators used for interpolation (addition, multiply with float, division).

To render data, a vertex buffer of the data must be created. Vertex buffers are represented as RenderObjects, which can optionally be indexed. If they are indexed, they additionally require an index buffer. Vertex Data can be buffered as a vector of tuples (vertex by vertex) or transposed as a tuple of vectors (attribute by attribute).

RenderObjects can then be drawn onto the framebuffer using Pipeline::Draw. At the beginning of a frame, the framebuffer should be cleared with Pipeline::clear.

Additionally the library provides a small sampler class using stb_image for simple unfiltered texture accesses.

Building

Build using CMake.

mkdir build
cd build
cmake ..
make

To build the examples, pass -D BUILD_EXAMPLES=ON. The examples require freetype library and headers installed.

The framebuffer uses 32 bit BGRA as a default format but can be set to use 32 bit RGBA with -D USE_RGBA=ON.

To include in a separate Project add this to CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(
    sr
    GIT_REPOSITORY https://github.com/aschmidt46/software-renderer
    GIT_TAG master
)
FetchContent_MakeAvailable(sr)

...

target_link_libraries(<target> PRIVATE software-renderer)

Then simply include the necessary headers directly.

Current Limitations

  • Limited performance
  • Vertex attributes not entirely arbitrary
  • No Clipping of Triangles overlapping the viewport

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages