Examples and tutorials » Area Lights

Basic real-time area lights.

Image

This example is a basic implementation of Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. Three lights are displayed, each with different orientation and parameters.

Controls

  • W / A / S / D — move camera
  • Mouse drag — look around
  • R / Shift R — increase / decrease roughness of the plane
  • M / Shift M — increase / decrease metalness of the plane
  • F / Shift F — increase / decrease $ f_0 $ (specular reflection coefficient) of the plane
  • F5 — reload shaders

Roughness, metallness and $ f_0 $ can be also configured through the UI.

Credits

This example was originally contributed by Jonathan Hale. The implementation is based on the paper "Real-Time Polygonal-Light Shading with Linearly Transformed Cosines" by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. The *.dds files are republished with a permission from Eric Heitz. There's also a Guest Post introducing this example on the Magnum Blog.

The example makes use of the Adobe Source Sans Pro font through the Ui library, see its documentation for license information.

Source

Full source code is linked below and together with assets also available in the magnum-examples GitHub repository. This example depends on the Ui library and the DdsImporter plugin which are not a part of the core Magnum repository, see their documentation for usage instructions.

The ports branch contains additional patches for Emscripten and OpenGL ES support that aren't present in master in order to keep the example code as simple as possible.