Penumbra allows users to easily add 2D lighting with shadowing effects (for both umbra and penumbra regions) to their games.
Currently available only for MonoGame WindowsDX platform targeting .NET 4.0!
Install through NuGet:
Install-Package Penumbra.MonoGame.WindowsDX -Pre
In the game constructor, create the penumbra component and add to components:
penumbra = new PenumbraComponent(this);
Components.Add(penumbra);
In the game's Draw
method, make sure to call BeginDraw
before any other drawing takes place:
penumbra.BeginDraw();
GraphicsDevice.Clear(Color.CornflowerBlue);
...
This will swap the render target to a custom texture so that the generated lightmap can be blended atop of it once PenumbraComponent is drawn.
Penumbra supports three types of lights: PointLight
, Spotlight
, TexturedLight
While PointLight
and Spotlight
are generated on the shader, TexturedLight
allows for more customization by requiring a custom texture used for lighting.
Lights provide two types of shadowing schemes: ShadowType.Illuminated
, ShadowType.Solid
To add a light:
penumbra.Lights.Add(light);
Hulls are polygons from which shadows are cast. They are usually created using the same geometry as the scene and can be ordered both clockwise or counter-clockwise. Hull points can be manipulated though the hull.Points
property.
For a hull to be valid and included in the shadow mask generation, it must conform to the following rules:
- Contain at least 3 points
- Points must form a simple polygon (polygon where no two edges intersect)
Hull validity can be checked through the hull.Valid
property.
To add a hull:
penumbra.Hulls.Add(hull);