Deferred Lighting via Compute Shaders

Started by
1 comment, last by Schrompf 12 years, 1 month ago
Recently i implemented Deferred Tile lighting via compute shaders. took me a little bit of time, as debugging the compute shaders wasn't fun. BTW, we need a debugging method for that.

on to my questions though. So my compute shader takes a buffer of point lights, and determines which lights are visible for each tile, and then executes the lighting equation. this is standard.

1)if i wanted to add in spot lights, what would be the best approach.

-expand my pointLight structure to house the additional properties needed, and then also add a type member so that the shader knows which lighting and frustum culling method to use?

-create a seperate light buffer just for the spot lights, and add an extra pass via the compute shaders to run thru the spot lights?

2) since i have this nice buffer of lights, is there any way i can utilize it inside of a compute shader to handle shadows?

-i am pretty sure i can't do the shadow calcuation at the same time as the lighting calcuations.... or is there....

-other ideas.

thanks much in advance
Code makes the man
Advertisement
For #1, the only real way to know is to try both and profile to see which is faster. With compute shaders you can often make a change that makes your shader faster on one GPU, but slower on another.

For #2, you're going to need to render your shadow maps ahead of time. To make it a bit easier on yourself you can use a texture array.
As long as you're not dealing with shadows, enhancing your point light structures to cover spot lights would probably the better approach. It's just a few additional math ops, which GPUs are really good at. But as soon as shadows enter the arena, a separate pass would be better, I think. Point lights usually need a cube map or maybe a dual paraboloid maps, but it definitely differs from the plain and simple shadow handling of a spot light. You could reunite the both if you manage to put all shadow information on the same resource type, for example by unfolding your cubemaps manually, but I'm not sure if this gains you anything.
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.

This topic is closed to new replies.

Advertisement