This is a simple a realtime open-source software renderer that emulates the OpenGL graphics pipeline. It utilizes few dependencies and is built mostly from scratch and written in C++98/C++11. The goal of this project is to build a renderer without the help of any Graphics API such as DirectX, OpenGL or Vulkan. Therefore it doesn't utilize any hardware acceleration provided by the GPU.
- Wireframe rendering
- Flat Shading
- Gouraud Shading
- Phong Shading
- Diffuse Texture Mapping
- Scene Switching
- Rendermode Switching
- OBJ file parser
- JSON file scene description
- Backface culling
- Depth Buffering
- Perspective correct interpolation
- Extendable vertex and fragment shaders
- Linear Algebra library
- Rasterizer
- Line Rendering
- SDL2 : Window context and to pass color buffer
- stbi_image: Load textures
- nlohmann json: Parse scenes file
The JSON file config.json, located in the directory Resources, allows the user to describe one or multiple scenes and objects. The scene description file should follow the format below:
{
"myscene_name":
{
"myobject_name":
{
"model": "mypathto/myobjectmodel.obj",
"diffusemap": "mypathto/mytexture.png",
"material":
{
"ambient": [0.15, 0.55, 0.85],
"diffuse": [0.55, 0.12, 0.23],
"specular": [1.0, 1.0, 1.0],
"exponent": 20.0
},
"transform":
{
"position": [0.0, -0.75, -10.0],
"rotation": [0.0, 0.0, 45.0],
"scale": [1.5, 1.5, 1.5]
}
},
... more objects
},
... more scenes
}
In the same directory, there is already a filled config file which can be used as an example. Currently only triangulated obj models are supported and for textures JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC (stbi_image).
Once the scene description filled in, the program can be started. Use the arrow keys (left and right) to switch between the different scenes. The spacebar on the other hand will switch between the different render modes and shaders.
The renderer in it current state has very little optimizations because it was first intended to get things working. As consequence the renderer might have a hard time to keep a decent framerate when provided with a high poly count mesh. Optimizations are definetely on my todo list. Mtl files are currently not supported. Normals and texture coordinates are required in the mesh models.
https://www.youtube.com/watch?v=7sPPdtgjI90
- Scratch A Pixel
- Tiny Renderer
- Leanrn OpenGL
- Mathematics for 3D Game Programming and Computer Graphics, Eric Lengyel
- Utah Teapot, The University of Utah
- Suzanne Blender, Blender Foundation
- African Head, Vidar Rapp
- Diablo, Samuel (arshlevon) Sharit
- Illidan Stormrage Legion
- Wolf's Edge - World of warcraft
- Low Poly Guitar
- Low Poly Helmet
- Low Poly RaceCar
- Cerberus Gun