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.

Shadows

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

Post processing

The code follows examples outlined in:

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.

    Shadow off Shadow on

  • 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.

    Shadow acne on Shadow acne off

  • 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.

    Depth averaging off Depth averaging on

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.

    No filter

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

    Edge detection filter

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

    Emboss filter

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

    Inversion filter

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

    Blur filter

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

    Top-Sobel filter

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

    Grayscale filter

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

    Sharpen filter