PDA

View Full Version : Fast way to clip non lit pixels in a lightvolume



saski
10-23-2014, 03:58 AM
Hello,

currently I'm working on a deferred shader engine with dynamic pointlights. To reduce fragment shader invocations I use stencil lightvolumes. However the result shows many lit pixels in areas where the light is completely occluded (below screenshot shows the geometry inside a lightvolume. The lightsource is the red torch. There is light on fragments where it shouldn't be obviuously.). What is the fastest way to reject fragments that are facing away or are in front of a pointlight source?

I guess I have to apply some sort of shadowmapping from the viewpoint of the lightsource. Or is there a better faster way with the approach described above?

1494

Any thoughts?

Mikkel Gjoel
10-23-2014, 07:24 AM
Yup, shadowmapping, e.g. http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/

Mikkel Gjoel
10-23-2014, 07:28 AM
...for point-lights, the easiest is the use a depth-cubemap... slightly harder is doing a dual-paraboloid shadowmap...
http://graphicsrunner.blogspot.dk/2008/07/dual-paraboloid-shadow-maps.html

Making it fast from there is all pain and suffering for eternity, or a lucrative authorship depending on how you look at it :) http://roy-t.nl/files/High_Quality_Adaptive_Soft_Shadow_Mapping.pdf

saski
10-23-2014, 08:10 AM
Yeah I thought so. found a nice tutorial also http://ogldev.atspace.co.uk/www/tutorial43/tutorial43.html
But I'm a little fuzzy on how to combine the shadow cubemaps with deferred stencil lighting.

I guess I have to do the shadowmapping first and in a subsequent pass and sampling the shadow depthbuffer when rendering the pointlight stencil volumes, right?

mhagain
10-23-2014, 11:18 AM
The basic algorithm goes like this this:


- draw all opaque geometry to gbuffer
- for each light
- draw all geometry to shadow map
- draw light volume
In other words, deferred is great for lots of lights but you lose much of that advantage as soon as you start adding shadows, particularly if you want a general-purpose lighting setup where you have lots of lights and each light must cast a shadow.

Shadow mapping is very much it's own world of pain, and you'll find yourself spending lots of time tweaking depth bias values and making fine adjustments to shadow map size. The reality is that we just don't have a 100%-robust-works-all-the-time-and-runs-fast general-purpose lighting and shadowing solution. The whole thing is crutched-up by a bunch of tweaks, approximations and trade-offs, and even the best lighting engines make compromises. The trick is to find the set of compromises that work well for you.