SuzanneIsland: An island of Real-time rendering effects!
Public Member Functions
LightbeamsEffect Class Reference

LightbeamsEffect Based on Kenny Mitchell "Volumetric Light Scattering as a Post-Process" http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html. More...

#include <lightbeams_effect.h>

Public Member Functions

 LightbeamsEffect (int windowWidth, int windowHeight)
 
void bindOcclusionFrameBuffer ()
 
void bindFrameBuffer (GLuint frameBuffer, int width, int height)
 
void bindDefaultFrameBuffer ()
 
ShadersetupLightbeamsShader (const glm::vec3 &sunWorldPos, const glm::mat4 &viewProjMat)
 

Detailed Description

LightbeamsEffect Based on Kenny Mitchell "Volumetric Light Scattering as a Post-Process" http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html.

This is used to roughly simulate volumetric scattering as a screen space post process. Volumetric scattering makes us see light beams that wouldnt reach us directly due to some light being scattered towards us from each position on the beams. Along a light beam, photons may enter towards us via scattering or leave in other directions. Usually since our direction is just one of many possible scatter directions, scattering will mostly lead to decay of perceived light intensity with distance from sun. To simulate this, we let each fragment have sky color depending on how much non occluded fragments where closer to the sun, since each nonoccluded fragment could scatter to our occluded on which could then scatter towards us, but fragments after occluded fragments away from sun shouldnt be much brighter to roughly simulate volumetric shadow. Visually this may look like a radial blur, i.e. a smearing of colors radially outward around the sun: Sky colors will smear into occluded regions, occluded regions will smear (shadow) into non occluded regions.

In a PREPASS we render the whole screen to the occludedSkyColorTexture containing the colored sky with all geometry in front of it drawn black.

In a POSTPASS we render the lightbeams which we can then blend with our default framebuffer. The Lightbeams Shader works as follows: For each fragment we sample the sky between it and the sun (fixed numSamples independent of distance) If the sky is clear take its sampled color, if it is occluded the sample is black. Each fragment receiveds the SUM of all these samples, sample contribution decays based on distance to fragment. Color of a point on a light beam thus depends on how much of the lightbeam is occluded up to that point: If all is clear, we get a bright sky color at all points, that will fade due to decay. this will be like a bloom effect around the sun. If we have (sun)—xxxx-----—> where x marks occluded parts, Then those occluded fragments x will still have some sky color from the nonoccluded fragments before. And the nonoccluded fragments after the occluded ones will have a bit less sky color due to "shadowing".

Constructor & Destructor Documentation

§ LightbeamsEffect()

LightbeamsEffect::LightbeamsEffect ( int  windowWidth,
int  windowHeight 
)

SETUP PREPASS FRAMEBUFFER setup framebuffers with color texture attachment. depth attachment is not needed since all geometry is drawn black in prepass.

LIGHTBEAMS SHADER


The documentation for this class was generated from the following files: