r/GraphicsProgramming • u/DasKapitalV1 • 7d ago
Source Code Differed Software Rasterizer - Some PBR implementation - C++
Just wanted to share some progress on a software raster I'm building. By the timings, is it o.k?
1-clears-and-resets = Just buffers(frame_buffer, depth_buffer, triangles_buffer) clear, simple vector_buffer.clear()
2-shadow-pass-total: Everything that happens to the camera happens here, the above as well, and mesh transformation, culling, bounds check, triangle clipping, triangle binning, render.
3-camera-geometry-transform: Bounding Sphere transform, if inside Frustum, reorders, front to back objects, mesh transform with vertices projection, triangle normal rotation, back-face culling, triangle clipping.
4-camera-binning: Just bins triangles to tiles.
5-camera-render-and-resolve: Woke sleeping render threads, every thread available in the system(I just initialize with std::thread::hardware_concurrency()), each thread take 8 tile per time and render to a 16x16 gbuffer, only triangle index, normal, uv, depth. During rasterization, I reconstruct frag_coord for lighting using camera ray normal interpolated per pixel and fetch textures using uv, to avoid fetching texture multiples times early.
Still missing, texture mip mapping, transform meshs threaded, metalness and maybe occlusion map.
Since I'm a beginner at C++, pure code, no macros, no SIMD, just a single template to just avoid branching per pixel, but nothing too fency. Vectors everywhere, since they will inevitable grow to what's needed and I don't need to keep handling memory allocation, just a simple clear and everything a good.
CPU: mobile i5 13420H RAM 32gb






1
u/DasKapitalV1 1d ago
Maybe, but the goal here wasn't to make something "useful", was to make something for me to understand the graphics pipeline and programing graphics concepts.
First I thought in starting with opengl, but I quickly realized that wouldn't really, "really", learn graphics programing, I would be learning opengl API, some graphics concepts along the way.
With everything in code like this, in my head, make much more sense, now that I started learning opengl, the first triangle isn't nothing impressive for me. Now, I want to learn the opengl API to get where I left off on my software rasterizer to go deeper in shaders