RapidGL
RapidGL copied to clipboard
Framework for rapid OpenGL demos prototyping
RapidGL
Framework for rapid OpenGL demos prototyping.
This framework consists of two major parts:
-
Core library - which is used as a static library for all examples. Source files are located in
src/core
. -
Demos. Source files are located in
src/demos
.
How to build
After cloning the repository, run one of the .bat scripts to generate Visual Studio 2019/2022 solution:
- setup_vs2019.bat - to generate VS 2019 solution.
- setup_vs2022.bat - to generate VS 2022 solution.
Or run the following command in the root directory to generate project files with the default build system for your system:
cmake -B build
Either of these approaches will create project files in the build directory.
How to add a new demo using Template Project
The following instructions are also located in src/demos/00_template_project/template_project.h
.
To begin creating a new demo using RapidGL framework follow these steps:
- Create new directory in
src/demos/<your_dir_name>
. - Add the following line to
src/demos/CMakeLists.txt
:add_subdirectory(<your_dir_name>)
. - Copy contents of
src/demos/00_template_project
tosrc/demos/<your_dir_name>
. - Change target name of your demo in
src/demos/<your_dir_name>/CMakeLists.txt
fromset(DEMO_NAME "00_template_project")
toset(DEMO_NAME "your_demo_name")
. - (Re-)Run CMake
Notes: After changing class name from e.g. TemplateProject to something else, update main.cpp
in <your_dir_name>
accordingly.
Examples
All of the demos are available in src/demos
.
Template Project

Simple Triangle

Simple 3D
This demo shows how to create camera, load models, generate primitives using built-in functions and add textures for specific objects.

Lighting
This demo presents implementation of Blinn-Phong shading model for directional, point and spot lights.

Multitextured terrain
This demo presents implementation of multitextured terrain. It uses a blend map (for varying X-Z texturing) and slope based texturing (for texturing the slopes).

Toon shading
This demo presents implementation of various toon shading methods (Simple, Advanced, Simple with Rim, Twin Shade) with different outline rendering methods (Stencil, Post-Process).

Simple Fog
Implementation of a simple fog rendering. Three modes are available: linear, exp, exp2.

Alpha Cutout
This demo shows implementation of an alpha cutout using fragments discarding.

Environment mapping
Implementation of dynamic and static environment mapping (light reflection and refraction).

Projected texture
Demo presents projecting a texture onto a surface.

Postprocessing filters
Negative, edge detection (Sobel operator) and Gaussian blur filters demo.

Geometry Shader: Point Sprites
Demo presents generation of quad sprites from points data using Geometry Shader.

Geometry Shader: Wireframe on top of a shaded model

Tessellation - 1D

Tessellation - 2D

PN Triangles Tessellation with Level of Detail
This demo implements Point-Normal tessellation algorithm (see main.cpp for references) with depth based level of detail (NOTE: works for each mesh with vertex normals).

Procedural noise textures

Surface animation with vertex displacement

Simple particle system using Transform Feedback
Available presets: fountain, fire and smoke.

Particle system using instanced meshes with the Compute Shader

Mesh skinning
This demo presents simple model animation system using Assimp. There are two skinning methods available: Linear Blend Skinning and Dual Quaternion Blend Skinning.

Order Independent Transparency (OIT) with MSAA
Order Independent Transparency using linked lists (per pixel) with MSAA.

Physically Based Rendering (PBR)
Including directional and punctual lights (spot and point) with square falloff attenuation. The demo supports textured and non-textured objects.

Geometry Shader: Face Extrusion

Percentage Closer Soft Shadows (PCSS)

Cascaded Percentage Closer Soft Shadows (CPCSS)

Bloom
Bloom implementation based on Call of Duty: Advanced Warfare Jimenez14. Implemented using Compute Shaders with shared memory utilization for improved performance. Full bloom pass (1920x1080) takes ~0.75ms on NVidia GTX 1660 Ti with Max-Q Design (according to NVIDIA Nsight Graphics).

Clustered Forward Shading
Clustered Forward Shading implementation based on Clustered Deferred and Forward Shading (2012) (Ola Olsson, Markus Billeter, Ulf Assarsson) and Jeremiah van Oosten's DX12 demo.
For light culling, I used view aligned AABB grid. During the lighting stage, only the visible clusters are taken into account (it greatly improves the performance as we limit the searching domain).
The demo is able to render ~100k lights at interactive frame rates (> 30FPS) on NVidia GTX 1660 Ti with Max-Q Design at 1920x1080 resolution.
To further improve the performance, you may look into adding lights BVH structure as described in O. Olsson's paper. Jeremiah van Oosten's DX12 demo includes the fully optimized version of clustered shading algorithm. I highly recommend looking into it.
19/07/2023 update: The demo now also supports the LTC Area Lights based on Eric Heitz's paper Real-Time Polygonal-Light Shading with Linearly Transformed Cosines (2016). The area lights are also being culled by the clustered shading algorithm.

