Shadows in 2D deferred rendering

Hello,

I’ve successfully gotten a 2D deferred rendering shader working. However, now I’m trying to use this to cast shadows. The problem I seem to have conceptually is that I simply don’t have enough data in my GBuffer to be able to tell where shadows should be cast. For example, if I draw some foreground in front of something solid that I want to cast a shadow, then this solid object’s existence would be completely unknown to the deferred rendering code, since it is simply not visible in the final render of the scene. How can I get around this? Or do I need to use something other than deferred rendering?

Thanks

As you already work with deferred, you could just add another rendertarget (or use a channel of an existing one) to store information about solid objects and use that for shadowing purposes - in case this is helpful, as I have no clue how shadows would be done that way in 2D.

In a forward renderer you could just use the stencil buffer (and basically you could do the same in a deferred one but it needs a bit more care then)

I guess you have to render a shadow map, from the perspective of the light. The GBuffer is rendered from a different/wrong perspective (the camera’s)

Yes, after some research this seems to be the only way without having to complete overhaul the way I’m doing it. I’ve decided that this isn’t worth the results, so I’ll leave shadows from my Game. Thanks anyway