Retained mode, deferred BPR 3D renderer.
- Still in working progress (the API still misses some things)
Or check out my 2D rendering library!
- From the headerOnly folder add the .h and the .cpp files in your project.
- You should also have GLM and stb_image and stb_truetype working. You can also find them in dependences.zip.
- This library uses opengl so you should have the functions loaded. You can do it however you want but you should load them before using the library
How to compile the repo (Visual studio 2019, Windows)
If you want to edit the project this are the steps to follow. It is not required to do this tu use the library on your project
- Clone the repo then
- in the repo directory, unzip dependences,
- You must have python 3 on your machine for the header only version to be compiled.
Features and todos:
- Loading .obj Models (with materials)
- Loading .mtl Materials (just the materials)
- Loading .gltf / .glb Models (with materials)
- Normal mapping (TBN calculated per fragment)
- Phisically based rendering
- Phisically based materials
- Sky box (can load many formats)
- Image based lighting
- Light sub scattering for IBL as described here http://jcgt.org/published/0008/01/03/
- Screen space reflections
- Environment probes
- Deferred rendering
- Optimize lights (less calculations for many lights)
- Optimized G buffer
- Deferred materials system
- Gama correction
- HDR, ACES tonemapping
- Automatic exposure ajustment for HDR tonemapping
- FXAA
- Adaptive resolution
- TAA
- Store all the render data before rendering (used for depth pre pass)
- Improve the deferred rendering by adding bindless things
- Only one geometry buffer and a dynamic index buffer
- SSAO
- SSAO settings
- SSR
- SSR settings and profiles
- Bloom
- Bloom settings
- Emissive materials
- Volumetric light (God rays)
- Directional, Spot and Point Lights
- Shadows for all types of lights
- Cascaded Shadow Maps for directional lights
- Baked lighting for static geometry
- Shadows settings per light (hardness)
- Set shadow quality globally
- Chromatic aberation
- Color correction (color grading)
- Animations
- Skinning matrix computed on the gpu
- Transparency
Whenever the render function is called, this steps are taken:
-
Adaptive resolution size is calculated based on the average milliseconds per frame, and used for the current frame
-
The skybox is rendered.
-
The skinning matrix for the animations are calculated
-
The shadow maps are rendered (The static geometry is cached into a texture (one texture per light) and the dynamic geometry is rendered on top of the cached texture)
-
Bindless textures are setup (setting the texture id of the material, this step could also be used if I would want to controll what textures are loaded to the gpu (for now all textures are resident to the gpu memory))
-
Z pre pass if enabeled (I still have it as an option but the new deferred pipeline doesn't seem to benefit) + Frustum culling is calculated
-
The geometry buffer is rendered, this is the first step of a deferred rendering engine. I only render the geometry to a big buffer. I have the frustum culling calculated so now I know what to render and what not to render. The gBuffer looks like this in my implementaion:
- Normal, GL_RGB16UI (stored in a custom format)
- textureDerivates, GL_RGBA16UI (stored in a custom format)
- positionViewSpace, GL_RGB16F
- materialIndex, GL_R16I
- textureUV, GL_RG32F
- depth, GL_DEPTH_COMPONENT24
my deferred material implementation doesn't render to the g buffer lighting information but rather the material index that is later used to get the texture information. This Significatly speeds the geometry pass. The materials are all stored into a global buffer (and I also use lazyness on copy materials). The textures are sampled using bindless textures so we can draw the entire lighting pass with one draw call no matter how many materials. This implementation would also allow for a possible future implementation of a global geometry buffer.
-
The lighting pass: the geometry information is in a buffer and now a shader will calculate the lighting information
-
Steps 7 and 8 are repeated fot the transparent geometry. No transparency tehnique is used so far but with this setup I'll probably implement a simple depth peel.
-
SSAO is calculated (ssao is calculated at half resolution for performance reasons (and if adaptive resolution is on the viewport will be even smaller than half the window size))
-
Bloom data is extracted and then blured (again half resolution). The blur works by bluring and scalind down the immage, untill it is very small, and finally adding all the mips to get the final rezult.
-
Last post proces step: (fxaa, traw to the screen the final exposed HDR rezult and chromatic aberation)
Materials are handeled by the engine using an internal id. When creating a material it will also create the associated PBR texture
Cpu entities will hold a weak refference to graphic models, and will also create gpu data (for skinning matrix)