WARNING : OpenGl 4.5 is needed to run the project.
- Using
- Building the project
- Running the project
To move the 3D model, use the mouse:
- left click + move the mouse to rotate
- middle click + move the mouse to zoom-in or zoom-out
- right click + move the mouse to move the model over X and Y direction
PBR was implemented using GGX microfacet model. It uses material albedo parameters that can be imported from a texture and a number of lights that can be changed.
PBR with GGX microfacet model
To use more or less lights, use keyboard's up and down arrows. The lights are designed according to the 3-points lighting method.
3 point-lighting with key light, fill light and back light
To enable or disable teXturing, press the X key. By default, it textures the model with brick appearance.
Texturing with brick
To add new textures, create a new subfolder in Resources/Material and add the texture files. The texture can be changed using the MATERIAL_NAME variable in Main.cpp. To do so, replace
static const std::string MATERIAL_NAME ("Brick/");
by
static const std::string MATERIAL_NAME ("Name/");
where Name is the name of any subfolder in Resources/Material.
To enable or disable Normal-mapping, press the N key. The texture used for normal-mapping is the one used in the Resources/Material/MATERIAL_NAME folder.
Normal mapping
Normal mapping with textured 3D model
As the UV coordinates of the textures does not fit the 3D model, normal discontinuities can be perceived along the plane Z = 0.
Normal mapping discontinuity
While PBR aims to render images as photorealistic as possible, Toon-shading is a non-photorealistic rendering based on expressived styles.
To enable and disable Toon-shading, press the T key.
The default Toon-shading is a commonly used 1D texturing.
Toon-shading
The colors:
- black for the edges
- white for highly specular areas (i.e. light is mainly reflected in the direction of the camera)
- green for the rest
Default shading mode can be recovered using the 1 numeric key.
X-Toon shading is a method described in the paper X-Toon: An Extended Toon Shader written by Pascal Barla. Instead of providing a 1D texture to perform an expressive rendering, a 2D texture can be used. This way, the toon-shading is extended by a criteria. List of commonly used criteria:
- distance to the camera along camera axis (press the 2 numeric key)
- distance to the camera along focal axis (press the 3 numeric key)
- orientation of the surface with respect to the camera (press the 4 numeric key)
X-Toon shading with a distance to the camera along camera axis criteria
The resulting effect is that color changes are more sudden in the farthest regions than in the nearest ones. This way, less attention is paid to the silhouette. This effect only depends on the texture and the criteria.
In several applications, 3D models are not rendered in totality but modified before. For example, there is no need to render all the details of a far tree if only three pixels are affected by this model.
Playing with the sections below will distord the model with no doubt. To load the proper initial 3D model, press the F5 key.
A Laplacian filtering can be performed. The idea is to move vertices along their Laplacian to filter details. To perform a Laplacian filtering, press the I, O and P keys. Each key has an associated coefficient. The higher is the coefficient, the fewer is the number of iterations needed to filter the model. But the lower is the coefficient, the more precise is the filtering.
- I moves vertices from 0.1 of the Laplacian vector
- O moves vertices from the half of the Laplacian vector
- P moves vertices from the entire Laplacian vector
Laplacian filtering
The 3D model can be simplified using clustering.
To Simplificate the model with a predefined resolution, press the S key. To simplificate the model using an Adaptaive resolution implemented with an octree, press the A key.
Predefined simplification
A shader is used to compute a depth map from the light point of view (for now, only the key light is considered) and write it in a texture using a framebuffer.
Depth mapping with light point of view
To visualize the result of the shader, press the 5 numeric key.
A shader computes, for all fragments, the distance the light has traveled in the object. This is used to render the subsurface scattering effect.
Distance traveled by light from the point it enters the object to the fragment
The Phong computation is augmented with the subsurface scattering contribution when pressing the B key. Pressing B key again display the subsurface scattering effect only.
Result of the subsurface scattering, with light behind the object
The subsurface scattering contribution is exponentially decreasing as the distance traveled by light increases.
Without Subsurface scattering
With Subsurface scattering
Subsurface scattering only
Subsurface scattering x3
This is a standard CMake project. Building it consits in running:
cd <path-to-BaseGL-directory>
mkdir build
cd build
cmake ..
cd ..
cmake --build build
The resuling BaseGL executable is automatically copied to the root BaseGL directory, so that resources (shaders, meshes) can be loaded easily. By default, the program is compile in Debug mode. For a high performance Release binary, just us:
cmake --build build --config Release
To run the program
cd <path-to-BaseGL-directory>
./BaseGL [file.off]
Note that a collection of example meshes are provided in the Resources/Models directory.
When starting to edit the source code, rerun
cmake --build build
to recompile. The resulting binary to use is always the one at located in the BaseGL directory, you can safely ignore whatever is generated in the build directory.