A simple compute shader fixed-function rasterizer with hierarchical z-buffer culling in OpenGL 4.6.
(Also project for Zhejiang University 2022-2023 Autumn-Winter Advanced Computer Graphics master course)
Usage:
cs-rasterizer <path-to-scene-file>
A scene file can be a .obj
file or a .json
scene file, see scenes
folder for details.
CMake is used to build this project.
C++20 is needed.
For simplicity, shade fragments with world space normal.
3 rasterizer shaders are implemented:
- Just loop in the bounding box of triangle. (
basic_z.comp
) - Scanline from top to down while maintaining horizontal boundary. (
scanline.comp
) - (Default) Push each triangle and corresponding horizontal boundary to per-line lists and dispatch another pass to draw. (
line_tile_pre.comp
andline_tile_draw.comp
)
2 kinds of Hi-Z culling are implemented:
- Check each instance's bounding box. (
simple_hiz
) - Do culling through scene octree. (
octree_hiz
)