hello again, this time im doing deferred lighting following this concept:
http://kayru.org/articles/deferred-stencil/
ive got it implemented, but some questions remain...
-in the first pass you need to turn off color, while the second one draws to the rendertarget. at the moment i achieve this by setting the rendertarget to 0 during the first pass. however rendertarget switching is expensive, so i wonder if i should do this maybe with alpha blending. i know i can simply try it out, but i don't want a days worth of bughunting just to find out my original solution was better, and rather profit from someone elses experience. any other clever (i.e. fast) ways to mask out color drawing?
-also, when doing multiple lights, i save a light color and specular factor in the rendertarget and accumulate values for all lights in the same target. is this the right way to do it?
in pseudocode, i do a loop over my lights which looks something like this:
for (all lights)
{
set_rendertarget(null,depthstencil)
renderfrontfaces()
set_rendertarget(colorbuffer,depthstencil)
renderbackfaces()
}
so my loop always switches between those targets, feels kinda expensive (atm my fps drop from 200 to 60 with 50 lights each covering ~30% of the screen, even though their pixelshader code does almost nothing, only a tex lookup (well overdraw also kills fps, but that much?)). doing the first pass with all lights, then the second doesnt work obviously, because backfaces of some light may coincide with frontfaces of another drawn earlier, and produce a draw area which should've been stenciled out.
im using dx11 btw, if it matters...
any thoughts how to do this properly is appreciated
cheers,
tasche