All Projects → discosultan → Penumbra

discosultan / Penumbra

Licence: mit
2D lighting with soft shadows for MonoGame

Labels

Projects that are alternatives of or similar to Penumbra

Barotrauma
A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
Stars: ✭ 547 (+164.25%)
Mutual labels:  monogame
Quake Console
Quake-style console for MonoGame
Stars: ✭ 66 (-68.12%)
Mutual labels:  monogame
Simplexrpgengine
Modular game engine built with MonoGame, with GMS2-like workflow and advanced level editor
Stars: ✭ 122 (-41.06%)
Mutual labels:  monogame
Pixelvision8
Pixel Vision 8's core philosophy is to teach retro game development with streamlined workflows. PV8 is also a platform that standardizes 8-bit fantasy console limitations built on top of the open-source C# game engine based on MonoGame.
Stars: ✭ 773 (+273.43%)
Mutual labels:  monogame
Monogame
One framework for creating powerful cross-platform games.
Stars: ✭ 8,014 (+3771.5%)
Mutual labels:  monogame
C3de
C3DE is a 3D Game Engine powered by MonoGame
Stars: ✭ 78 (-62.32%)
Mutual labels:  monogame
Openviii Monogame
Open source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
Stars: ✭ 424 (+104.83%)
Mutual labels:  monogame
Monogame.forms
MonoGame.Forms is the easiest way of integrating a MonoGame render window into your Windows Forms project. It should make your life much easier, when you want to create your own editor environment.
Stars: ✭ 165 (-20.29%)
Mutual labels:  monogame
Chaifoxes.fmodaudio
Cross-platform C# FMOD wrapper.
Stars: ✭ 50 (-75.85%)
Mutual labels:  monogame
P3d Legacy
Legacy repository for the Pokémon3D Visual Basic version
Stars: ✭ 122 (-41.06%)
Mutual labels:  monogame
Apos.input
Polling input library for MonoGame.
Stars: ✭ 25 (-87.92%)
Mutual labels:  monogame
Monogame.extended
Extensions to make MonoGame more awesome
Stars: ✭ 908 (+338.65%)
Mutual labels:  monogame
Pathrenderinglab
Repository for research on complete SVG rendering
Stars: ✭ 83 (-59.9%)
Mutual labels:  monogame
Awesome Monogame
A collection of interesting libraries/tools for Monogame based game projects
Stars: ✭ 655 (+216.43%)
Mutual labels:  monogame
Magicallife
A 2d game that aspires to be similar to Rimworld, with more depth, magic, and RPG concepts.
Stars: ✭ 145 (-29.95%)
Mutual labels:  monogame
Freeso
Re-implementation of The Sims Online.
Stars: ✭ 526 (+154.11%)
Mutual labels:  monogame
Nez
Nez is a free 2D focused framework that works with MonoGame and FNA
Stars: ✭ 1,168 (+464.25%)
Mutual labels:  monogame
Monofoxe
Foxes made Monogame easy.
Stars: ✭ 175 (-15.46%)
Mutual labels:  monogame
Protogame
This project has been sunset as of 1st Jan 2018 and is no longer supported or maintained
Stars: ✭ 166 (-19.81%)
Mutual labels:  monogame
Easy Extends
一个简单快速安装PHP扩展的程序--最简单的方法就是使用Linux
Stars: ✭ 85 (-58.94%)
Mutual labels:  monogame

What is this sorcery?

Penumbra allows users to easily add 2D lighting with shadowing effects to their games.

Note that this project is no longer in development. I do try to fix any bugs though!

Platformer2D sample

Getting Started

Building source and samples

The following is required to successfully compile the Penumbra MonoGame solution:

Using Penumbra

Currently available only for MonoGame WindowsDX platform targeting .NET 4.5+!

Install the assembly through NuGet:

Install-Package MonoGame.Penumbra.WindowsDX

In the game constructor, create the Penumbra component and add to components:

PenumbraComponent penumbra;

public Game1()
{
  // ...
  penumbra = new PenumbraComponent(this);
  Components.Add(penumbra);
}

In the game's Draw method, make sure to call BeginDraw before any other drawing takes place:

protected override void Draw(GameTime gameTime)
{
  penumbra.BeginDraw();
  GraphicsDevice.Clear(Color.CornflowerBlue);
  // Rest of the drawing calls to be affected by Penumbra ...
}
...

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.

By default, Penumbra operates in the same coordinate space as SpriteBatch. Custom coordinate space can be configured by setting:

penumbra.SpriteBatchTransformEnabled = false;

Custom transform matrix is set through the Transform property.

Working with lights

Penumbra supports three types of lights: PointLight, Spotlight, TexturedLight

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 three types of shadowing schemes: ShadowType.Solid, ShadowType.Occluded, ShadowType.Illuminated

Solid Occluded Illuminated

To add a light:

penumbra.Lights.Add(light);

Working with shadow hulls

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 through 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);

Assemblies

  • MonoGame.Penumbra: The core project for the lighting system.

Samples

  • HelloPenumbra: Simple sample which sets up bare basics of Penumbra with a single light source and shadow hull.
  • Platformer2D: Penumbra lighting applied to MonoGame Platformer2D samples game.
  • Sandbox: Generic sandbox for testing out various different scenarios.
  • Common: Supporting library providing common functionality for samples.
  • FarseerPhysics: Create physical bodies out of sprites and add them as hulls to Penumbra!

Development

Release a New Version

  • Make sure version numbers are updated in .csproj files.
  • Create packages:
dotnet pack -c Release MonoGame.Penumbra.DesktopGL.sln
dotnet pack -c Release MonoGame.Penumbra.WindowsDX.sln
  • Publish packages (substitute <version> with version to be released):
VERSION=<version>
dotnet nuget push Source/bin/Release/MonoGame.Penumbra.DesktopGL.$VERSION.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
dotnet nuget push Source/bin/Release/MonoGame.Penumbra.WindowsDX.$VERSION.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].