C++ 3D Engine

Francisco Nicolau
Nico’s SoftwareDev Projects
4 min readMar 19, 2021

Simple Real-Time 3D Scene Editor built with C++ and OpenGL

Project Description

This project was developed in 2021 for my Master’s Computer Graphics Class by me and three other classmates. Our initial assignment consisted of creating a bare-bones 3D engine using C++ and OpenGL. The purpose of this task was for us to learn the basics of real-time rendering using a graphics API as well as how to build an abstracted framework for a 3D application.

In the second part of the semester, we ended up expanding on this project by adding new features and capabilities inspired by 3D editors like blender3D.

The code is available on Github if you want to take a look: https://github.com/jovmar34/AVT_Proj

Features

In the video above you can see an overview of all the features that we managed to implement as part of this project. In this section, I will briefly go over some of the aspects that I personally focused on.

Shading

In order to perceive the three-dimensionality of any given mesh object, 3D editing software often employ the use of non-photorealistic shading. This gives the user the impression of shadow, light, depth, and volume.

To achieve this we implemented several vertex and fragment shaders to create support for a few shading models. Namely, Phong, Gouraud, Blinn-Phong, Toon, and Gooch shading. All of these shading styles help the user not only perceive form but also create a visual distinction between objects.

Examples of the shading models available

Texturing

Paired with the different shading models is also the necessity to import images and render them at will. This allowed us to create shaders that used the vertex UVs or the lighting information (eg: toon shader) to sample a texture. To support the loading of image files of several different formats we used a single-file public domain library called stb_image (stb).

Example of four objects with different materials, with texturing support (plane object).

Material Abstraction

Much like all other programs, blender provides the notion of material.

Schematic of the abstractions created for the engine

A material is the association of a shading model with any given number of uniform values. We created this abstraction which allows us, for example, to create different color materials using a single shader with very few lines of code necessary.

Procedural Texture Grid

Following the previous point, we decided to use a procedural texture shader to create a visual indication of the world-space so the users know where the origin of the scene is, which axis is which and so they can have a better sense of scale and distance.

Infinite world grid effect with a procedural shader

Selection Outline Shader

To allow the user to tell which object is currently selected in the scene we created an outline effect to mimic the one from blender. This uses the common inverted-hull method which renders the geometry twice but avoids using an intensive post-processing shader and will also support the rendering of concave shapes and volumes with holes.

Developer Commentary

We also recorded a small developer commentary to give some insights on what each individual contributed to this project.

Closing Thoughts

I’m really glad I was able to dedicate as much time as I did to this project as it really made for an amazing learning experience that certainly left me with a much deeper understanding of the challenges involved in developing a 3D engine. It also helped me improve my knowledge regarding the techniques used in real-time rendering.

Computer Graphics continues to be an area of Computer Engineering that never ceases to fascinate me. The more I delve into it the greater my respect grows for the monumental efforts that have lead us to the technology that is available nowadays.

Thank you very much for reading. I hope you enjoyed it! 🤗

Example animation made in-engine.

--

--

Francisco Nicolau
Nico’s SoftwareDev Projects

I’m a CS Master’s student interested in using all sorts of technology as a medium to challenge myself and express creativity.