many people are saying defered shader is not accurate for transparency. I've done some with a small demo (Directx11) and would like to know the limit of this strategy when rendering opaque+transparent objects in deferred shaders. I would also like to know if it is possible to draw the shadow maps in the same MRT pass (provided there is 4 rendertargets) using maybe geometry shaders to change the transformed vertex output from world to light space? Note: because there's only one light i've found convenient to optimize one MRT as a single 8 bit (R8_UNIFORM) containing already calculated Dot3(N.L) and a specific blend ops for (let say ) good results. The colored shadow map comes from an explained demo seen somewhere in the web. The white color is needed to have correct colors for transparent shadows (otherwise they look darker). This technique is convenient for distant objects but not when they are too close because of possible self shadowing that is visible with transparent objects.
As I mention there is only one light used for this demo. This is why I'm using only R8 chanel to store dot3NL instead of the normal. This may save some resources and bandwitdh. Of course for many lights this will be a limitation of up to 4 lights per texture if you use RGBA chanels.
regarding the code it's quite simple
in VSchader output.norm = mul(input.norm, (float3x3(world))
in pShader
flot L = dot(input.norm, lightdir)
Output.Color1 (dot3map) = (Input.Col.a==1)?L:Input.Col.a*(1+L0.5f)
here for opaque object the dot3 is taken as such. for transparent object the dot result is modulated to take into account the transparency. Using just L value gives to transparent object an opaque darkness where light is not facing. Using Input.Col.a(1+L*0.5f) insures that the dark part of the transparent object is still transparent. Modulating the 1 and 0.5 value gives different transparent lighting results.
This result is also dependent on the blending operation.
Using Op ONE/ZERO Add and AlphaOp SRC_ALPH/INV_SRC_ALPHA Max gives darker blending than the one I used previously. As a result the object looks more like its shadow.This is what I'm using in the second image demo2 (with bump and reflexion added)