MiniRT
Graphics project for Codam / 42 school, my first ray tracer using MinilibX.
Project goal:
The goal of your program is to generate images using the Raytracing protocol. Those computer generated images will each represent a scene, as seen from a specific angle and position, defined by simple geometric objects, and each with its own lighting system.
Compiling
running make will compile the mandatory part, make bonus will overwrite and add the bonus. make clean or make fclean can be used to wipe binaries
Usage & Keybinds
Run using: ./MiniRT path/to/file.rt or ./MiniRT path/to/file.rt --save to render and save the image.
MiniRT supports files suffixed with the .rt extension. All rules from the PDF apply.
The two shell scripts in the root of this directory will run tests (using scenes/../error) to ensure these errors are handled properly.
Keybinds can be found in key.c for the mandatory part, or key_bonus.c for the bonus part.
key.c
Escape- Exit programEnter- Render scene1- Render image using flat shading2- Render image using unlit colors3- Debug bounding volumesComma- Previous cameraDot- Next camera
key_bonus.c
Escape- Exit programEnter- Render scene1- Render image using flat shading2- Render image using unlit colors3- Debug bounding volumes4- Debug Normals (Rainbow color bonus)5- Debug Units (Checkerboard pattern bonus)6- Debug UVs7- Debug DOFComma- Previous cameraDot- Next cameraW- Move forwardA- Move leftS- Move backD- Move rightQ- Move downE- Move upJ- Pan leftK- Pan downI- Pan upL- Pan rightU- Roll leftO- Roll rightT- Translation mode: edit position (if shape is selected)R- Translation mode: edit rotation (if shape is selected)X- Translation axis: XY- Translation axis: YZ- Translation axis: ZUp- Translate in the positive direction (if translation axis is set)Down- Translate in the negative direction (if translation axis is set)Plus- Increase FOVMinus- Decrease FOV
mouse_bonus.c
Mouse1- Select shapeMouse2- Deselect shapeMouse4- move the depth of field focal plane forward (BRDF only)Mouse5- move the depth of field focal plane back (BRDF only)
Debug modes
Left to right: Flat, unlit, normals, units and UVs
About
The mandatory part of the project requires you to code a classic one-ray-per-pixel style ray tracer. However for the bonus part of MiniRT i implemented a BRDF rendering equation to render more realistic looking scenes. This includes Global illumination, roughness materials, soft shadows and depth of field sampling. Another neat little feature is the rendering of complex .obj triangle meshes, using a BVH acceleration structure. Other fun things include material loading on top of the standard 8bit color defines.
MiniRT uses MinilibX, a small graphics library that allows for simple window management and putting pixels to the screen. The program can render the following shapes and scene elements using their respective identifiers:
Mandatory:
R- Window resolutionA- Ambient lightingl- Point lightc- Camerapl- Planesp- Spherecy- Cylinder (non-capped)sq- Squaretr- Triangle
Bonus:
SKY- Skybox loadingSUN- Sun rendering (emission BRDF only)THREADS- Multithreaded rendering (BRDF only)AA- Anti aliasing (Classic shading only), option to accelerateVP- Viewport resolution (downscaling for faster debugging)cb- Cube (6 squares)py- Pyramid (One square, four triangles)ds- Diskcyc- Capped cylindersobj- Triangle meshlp- Parallel light (fixed direction)
More about these identifiers can be found in the scenes directory
Other bonus subjects handled are:
- Normal disruption using sine over UV coordinates
- Color disruption: checkerboard pattern
- Color disruption: rainbow effect using object's normal
- One color filter: Gamma correction & Sobel edge detection
- Sphere texturing: uv mapping
- Shape texturing: uv mapping (All other shapes)
- Handle bump map textures (Normal map)
- Keyboard interactivity (translation/rotation) with the camera
- Keyboard interactivity (translation/rotation) with shapes
Mesh loading
Mesh loading is simple and limited, MiniRT will only parse vertices and triangulated faces. Vertex normals are computed by the program itself. an example of a working .obj file would be:
# www.blender.org
o dragon
v -0.090499 -0.115513 -0.093754
v -0.090303 -0.116237 -0.093008
v -0.090556 -0.115490 -0.093008
...
...
f 1 2 3
f 4 1 3
f 5 1 4
In blender, the export settings can include modifiers but the output has to be triangulated.
The model above consists of over 1.000.000 triangles, rendering these triangles is done through a Bounding Volume Hierarchy octree structure, which means the intersection tests are narrowed down and allows for faster rendering. I have attempted to make a comparison, but as it turns out.. rendering 1M triangles without a BVH structure is just not really what you want to be waiting on.
Depth of field
One of the things i personally enjoy is a good Bokeh, this describes the circular shape of the depth of field in current day cameras, as well as anamorphic ellipse-type shapes. Both of these have been implemented using the appropriate sampling methods, as well as a rejection method for custom lens shapes

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.











