shadow_mapping - JayDee-github/LearnOpenGL GitHub Wiki
Shadow-mappping and post-processing
This implementation applies shadow-mapping and post-processing techniques.
Coordinate transformations, projections and vector calculations are used to simulate shadows in a basic geometric scene.

Post-processing techniques are also used to create various after effects.

The code follows examples outlined in:
- https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping
- https://learnopengl.com/Advanced-OpenGL/Framebuffers
Changes over example code
- The ability to toggle shadowing effects.
- The ability to toggle post-processing effects.
Running the implementation
-
Navigate the Solution Explorer to path:
Solution -> 05.advanced_lighting -> 03.shadow_mapping_and_post_processing -
Left-click the project name and select Set as Startup Project from the pop-up window.
-
Press F5 to run the project.
Interfacing with the implementation
Exiting
Press the ESC key to exit the implementation.
Movement
The movement key-bindings follow an FPS-style scheme:
- W move forward
- S move back
- A move left
- D move right
- Spacebar move up
- Left-Shift move down
- Mouse-movement look around the world.
Rendering manipulations
The numeric keys 1-3 are used to select shadow-mapping algorithms:
-
1 Toggle shadow-mapping (off by default): There will be a couple graphical anomalies (bugs) present initially. The anomalies can be removed by toggling the 2 and 3 keys detailed below.

-
2 Toggle shadow acne (on by default): One of the bugs inherent in the original shadow-mapping algorithm is called shadow-acne. The bug happens because of the discrete resolution of the depth buffer. The bug is resolved by adding an offset to each calculation.

-
3 Toggle Depth-averaging (off by default): The shadow-mapping algorithm with the shadow acne fix gives realistic results. However, a closer inspection reveals pixilated edges of the shadows. The effect can be mitigated by running an averaging algorithm around the edges of the shadows.

Keys 8, 9, i, o, p, k and l are used to select post-processing effects:
-
8 No post-processing filter: the scene is drawn without post-processing effects.

-
9 Edge detection filter: implemented like a sharpening filter, but more contrast is added between edges.

-
0 Emboss filter: an effect that makes details on flat surfaces seem raised.

-
i Inversion filter: RGB colors in the scene are inverted.

-
o Blur filter: edges are averaged and less defined.

-
p Top-Sobel filter: an edge detection filter that emphasizes horizontal edges more than vertical edges.

-
k Grayscale filter: RGB colors are averaged and converted to a black and white spectrum.

-
l (lowercase "L") Sharpen filter: edges are more defined.
