Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Basic Volumetric Lighting (light shafts, god rays)

$
0
0

@Stephanowicz wrote:

Hi there!

Well after having a real hard time finding a SIMPLE example for casting light shafts I finally managed to port the Volumetric Lighting Tutorial by Nicolas Menzel to monogame.
His turorial is based on the GPUGems 3 article "Volumetric Light Scattering as a Post-Process" by Kenny Mitchell from EA
Surely there are lots of examples, but mostly in XNA4 or too complicated for me as a beginner.
The source by Nicolas isn't that simple, too, as there's lot of unused stuff - but I finally got it running!

So I put the project to gitHub and want to give a quick description, hoping that it may help others desperate like me finding a simple solution. :wink:

I've splitted the project into to parts - the uncleared original port, also containing all the unused original functions and a cleared, basic version with only the necessary stuff inside.
The original consisted of 2 projects I merged into one.
I'm using a different model, as I had problems with the original gears and the cube textures. I found a nice sphere with breakouts at cgtrader

I also added a controls-form for easily manipulating the light shaft parameters.


Project structure:

  • Game1.cs - the main game class
  • Controls... - the control form class
  • PostScreenEffects.cs - class for the post screen effect handling

As a raw order for generating a light shaft effect one could say:

  1. Generate several render targets for the different steps
  2. render the models with textures and other lighting (this step can be anywhere before steps 8,9)
  3. render an occlusion mask of the scene
  4. render the background texture containing the lightsource (the flare) and the occlusion mask to a new render target (blending)
  5. downscale the blended target from step 4 and apply a linear filter
  6. apply the lightshaft effect to this downscaled target
  7. upscale the result
  8. combine the targets (step 2 and step 7) to the final target
  9. draw the final target to screen

So far, for this moment… hope to add some more details next time!

Cheers,

Stephan

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles