Simple Software Graphics Engine(SSGE): A real-time and interactive 3D Renderer built from scratch in C++
SSGE is the result of a two month long learning project with the aim of building a real-time 3D renderer from scratch in C++. It is capable of modern Physically Based Rendering without making use of any third party graphics libraries such as OpenGL, DirectX or Vulkan. It is entirely software based and does not utilize any hardware acceleration throughout it's rendering pipeline. SSGE can run on both Windows and Linux machines by leveraging CMAKE for executable building and compiling and SDL2 for OS and hardware-level abstraction.
Performance wise, it is capable of running scenes containing medium size meshes of ~50k triangles and 4 light sources at a relatively stable frame rate of 30fps (Of course, your mileage may vary) while running the very demanding PBR shader. To achieve this it makes heavy use of multithreading, SIMD directives and various other optimizations such as early backface culling, frustrum culling and texture tiling among others.
You can download a demo of it for your machine here:
I am planning on starting a series of blog posts sometime soon that will explain some of the cooler components of the engine and how I went about implementing them. I also feel it would be helpful to other beginners to elaborate on some of the components that gave me the most trouble, such as how to design the general architecture of the engine, how to profile, optimize and bug fix your code and lastly how I personally tackled learning Computer Graphics coming from a non-cs background.
- Demonstrate my C++ Knowledge
- Satisfy a life long curiosity about computer graphics
- Keep the renderer Real-Time (original goal was 16ms actual ~29ms)
- Minimize external library usage to minimum
- Multiplatform development
- Use modern computer graphics techniques
- Learn to self-manage and architect "large" projects
I set these goals above as my learning targets for the project before I began and I have to say that I am very happy with how much progress I managed to make with most of them. If you're interested, I gave a talk that went more in detail about this and the journey in itself and you can find the slides for it here:
Talk Slides
- Parallelized forward renderer
- Programmable vertex & fragment shaders using C++ virtual functions
- Physically Based Shading
- Metallic workflow
- Cook-Torrance specular BRDF ( w/lambert diffuse)
- Perspective Correct Interpolation
- Tangent Space Normal Mapping
- Ambient Occlusion mapping
- Reverse (AKA logarithmic) Z-Buffering [1,0]
- Pre-vertex shader back-face Culling
- View Frustrum culling
- Gapless triangle rasterizer
- Fast Gamma correction
- Directional Lighting
- Bilinear Texture Filtering
- Seamless texture repeat
- Flat, Gouraud, Phong, Blinn-Phong shaders (deprecated in favor of PBR)
- SDL2 Backend
- Multiplatform executables
- Scene Switching
- Free moving camera
- Orbiting Camera mode
- Camera FOV controls
- Templated Vector Math / Linear algebra library
- .Obj file parser
- Scene content outlined in .txt file
- Texture tiling to reduce cache misses
- Multithreading per object and vectorization within lighting shader
- Fully commented for future referencing
- Image loading through stb-image [LINK]
- Axis aligned Bounding Box generation and reconstruction
- Moire Pattern and specular aliasing due to lack of texture minification
- Dark metallic objects due to lack of Image Based Lighting (or similar solution)
- Jaggies from lack of antialiasing
- No shadows causing undesired illumination in some models
- Stuttering during slow rotations from lack of sub-pixel precision
I've moved most of the sources into a separate page on the wiki for easier navigation and indexing. However, here are some of the ones I utilized the most:
- EDAN35 - High Performance Computer Graphics
- Stanford CS248, Spring 2018 - Interactive Computer Graphics
- ScratchAPixel
- Learn OpenGL
- Tiny Renderer
- Cerberus Gun Mesh & Textures by Andrew Maximov
- Utah Teapot with closed lid Mesh by Nik Clark
- Fire Hydrant & Chest by @emackey PBR test models
- Louis XIV de France, Louvre, Paris by HoangHiepVu
- Gold, Marble, Painted Metal by CC0Textures.com
- Azulejos Texture by João Paulo
- Elephant, Dragon, Bunny Mesh models from Stanford 3D Scanning Repository
If any of the above textures or meshes have been mis-acknowledged, are misattributed, or missing a proper reference please send me a DM on Twitter or email me at the address inside the source files and I'll fix it immediately.