Based on posts from GCElements I put my shadow calculations in the gbuffer for each light. In the vertex shader of the gbuffer I calculate the shadowCoords by putting P into shadowMapCam space by transforming P by the biasedShadowmapLight matrix. Then in the fragment shader I calculate the shadows with textureProj(shadowMapN, shadowCoordsN). I store this in the gbuffer with packHalf2x16() as a float and then read from it in the deferred shader.
//gbuf V v.shadowCoord0 = depthBiasMVP_0 * vec4(pE, 1.f); v.shadowCoord1 = depthBiasMVP_1 * vec4(pE, 1.f);
//gbuf F float shadowRead0 = textureProj(shadow0, g.shadowCoord0); float shadowRead1 = textureProj(shadow1, g.shadowCoord1); gBuf5.a = packHalf2x16(vec2(shadowRead0, shadowRead1));
This takes up a lot of space on my gbuffer as I add more shadow casting lights.
Is there a better way of doing this in the deferred lighthing shader? I’ve heard about writing multiple shadow maps onto a single texture.