A 3D Rendering Engine

Iver 15b47c0bc1 RI_free funcs now properly check if something was already freed 4 months ago
.vscode 34e507098f added vertex shader 4 months ago
build 15b47c0bc1 RI_free funcs now properly check if something was already freed 4 months ago
compiled_libs 15b47c0bc1 RI_free funcs now properly check if something was already freed 4 months ago
fonts d1f7fc1d23 updated API for request functions, fixed err in add_actors_to_scene where it took an array of actors, not an array of pointers 4 months ago
objects cebacbb8ac updated readme formatting, added cow 5 months ago
src 15b47c0bc1 RI_free funcs now properly check if something was already freed 4 months ago
textures a17168dd45 implemented sourparse 5 months ago
Makefile 5f68fe7caa added deltatime example to example scene 4 months ago
dbg 7ff5edccc0 added rendering & fixed object import bug 5 months ago
readme.md 5f68fe7caa added deltatime example to example scene 4 months ago
run a7f22d4dae first commit 5 months ago

readme.md

RasterIver

World's Best Renderer, 2025

How Does it Work?

Building Blocks

  • There are a couple fundimental elements of RasterIver: actors, textures, materials, meshes, and scenes (this isnt including internal ones like vectors and faces)
  • They all use pointers to reference objects
  • This allows multiple actors, for instance, to reference the same material or mesh
  • Because most things' attributes are a reference, a material can have a texture reference to the window! (it's frame buffer is an RI_texture)

Functions

  • There are functions such as RI_request_actors which creates new actors and returns a pointer to the list of total actors that exist in the RI context
  • Every function intended for the user will be prefixed with RI_

Rasterizer Pipeline

  • RI_render is called
  • RasterIver checks if the faces_to_render array is allocated (this is an array that stores every valid, renderable face in the scene and is specific to each scene) and if it isn't, it loops through every actor in the scene and checks the total number of faces, then allocates 2x the needed memory (this is because sometimes faces need to be split into 2, meaning that you need another slot where you previously only needed one)
  • faces_to_render is cleared
  • RasterIver loops through every actor and calculates the transforms of positions, normals, and uvs for face in the mesh (it also performs shrinking and splitting culling here), checks if it's going to be in view, is a valid face, or has should_render set to true. If it is a valid face, it is added to the faces_to_render at the first open slot as a RI_renderable_face struct. The AABB of the face is also calculated here
  • The target texture's image buffer and the z buffer are cleared
  • RasterIver loops through faces_to_render and then check every pixel in it's AABB and sees if it is inside the face. If it is, figure out what the color should be (does it have a material? A texture? Is it wireframe?)
  • When RI_tick is called, it copies the RI context's image buffer into the SDL texture and renders the frame onto the window (it also handles SDL events)

How to Run?

To run the binary, it needs to be in the same folder as librasteriver.so (if you just cloned the repo then they both should be in the build folder). You also need SDL2 installed (libsdl2-dev)

Todo List

  • checks for missing references
  • checks for missing files
  • debugging
  • 4 side+ polygons in the OBJ parser
  • negative UV and normals in the OBJ parser
  • .MTL support (?)
  • save scenes as templates? (files)
  • fix camera rotation code
  • OBJ parser issue with larger models? (idk, the teapot and gordon both dont work and I don't know why) [NOTE: it was because large models' faces randomly had should_render turned off. No clue why the small ones didn't but whatever]
  • aspect ratios other than 1:1
  • fix strange visual issue that happens when (speculation) a triangle gets culled and split very close to the clipped point [NOTE: it was a floating point precision issue. I changed all the floats to doubles and it's gone]
  • port CPU renderer to GPU
  • seams in objects
  • other object filetypes
  • flip texture function
  • multiple texture filetypes
  • texture resizing when passing in a different resolution than the texture is
  • built in meshes (cubes, sphere, torus, capsule, cylinder)
  • descriptions to variables and functions
  • normal map shading
  • bump maps
  • normal maps
  • memory tracker
  • tileable textures
  • UI elements (just images? text? custom text rasterizer? buttons?)
  • Documentation
  • text rasterizer for UI [NOTE: its for any texture in general]
  • texture masking; greyscale texture is used to filter out parts of another image. All white = keep the pixel, all black = make it transparent
  • add request empty texture
  • shaders. User makes a function for a pixel on a tri (passes a function as a pointer) and returns 1/0 whether to keep or ignore the pixel
  • add batch/blit object copying