Skip to content

gracejinsotrue/renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Real-time 3D graphics rendering engine from scratch except the part where i use sdl2. Has vertex editing and animation caching (e.g., sculpt facial expressions and save them as reusable animations)

Supports multiple 3D objects via scene graph hierarchy. Cool camera too.

Definitely a work-in-progress passion project meant to teach myself computer graphics and the heavy math behind it from the ground up (therefore everything is algorithmic), rather than trying to make this production-ready. Currently adding CUDA acceleration, trying to optimize performance for larger models (e.g. with backface culling or some shadow map caching for my potato computer (the former actually sped it up from like 10FPS to 30FPS so reallll))

GO TO:

some interesting rendered images

technical features

Engine screenshot

image image
gore_of_my_comfort_character_2.mp4
gore_of_my_Favorite_comfort_character.mp4

"that's gore of my comfort character" e.g. funny bugs

image

like any 3d engine, at certain angles, the geometry will look very weird.

image

Bro the way I learned Blender from scratch for this too:

image image

FEATURES

interesting technical stuff:

  1. generic computer graphics scene graph hierarchy: https://en.wikipedia.org/wiki/Scene_graph
  2. For the GPU acceleration aspect of my project, I used Nsight profiling. There exists Nsight profiling with a really easy script: nsys_easy that I used sometimes.
  3. two pass shadow mapping: the first pass renders a depth buffer from the light's perspective with orthographic projection. then, the second pass samples shaodw buffer during fragment shading. then we use an inverse transform to convert between camera space and light space.
  4. CUDA- accelerated triangle rasterization. The CPU rasterizing process processes one triangle at a time and loops through each pixel in a triangle's bounding box sequentially. This is slow. One core does all the work so true. But the CUDA implementation flips this arround by assigning one GPU thread to each pixel on the screen. The engine allocates GPU buffers for 1. vertices, 2. framebuffer and 3. depth and for each triangle it launches a kernel with 16x16 thread blocks. Each traingle INDEPENDENTLY computes barycentric coordinates to test whetehr the pixel lies inside the triangle, interpolates depth using those weights and writes to framebuffer if it does pass z-buffer test. Thousands of these pixels run in parallel across the GPU cores so true! Lowkey the tradeoff is memory transfer overhead because you need to transfer all vertices to GPU and then the finished frame back to the CPU so it wins on big fat models where paralleism outweighs copying cost.
  5. Möller-Trumbore Ray-Triangle Intersection technique for ray tracing path, it's a classic fast algorithm for ray-mesh intersection testing. more about Möller-Trumbore
  6. A classic Bounding Volume Hierarchy (BVH) acceleration structure for ray tracing! This builds upon Moller Trumbore and this is probably the easiest way to speed up anyone's ray tracer aside from like, backface culling stuff. This builds a spatial tree with axis-aligned bounding boxes (AABB) and. enables fast ray-object intersection testing in O(log n) time instead of O(n), drastically improving real-time ray tracing performance. more about BVH accelerated ray tracing

About

renderer engine from scratch such that i can custom render and animate my own 3d models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published