Advertisement

Rendering lights in deferred shading

Started by May 30, 2018 03:55 PM
10 comments, last by Vilem Otte 6 years, 8 months ago

About 5 lights (4 point lights, 1 spotlight) lighting the scene all with dynamic shadows (PCF & PCSS filtered), with deferred shading (and GI & realtime reflections):

many_shadows.png.e98d7459220734f173082f4ac3c98aa9.png

Now, I do know there is a lot of space to optimize this a lot more - but the important part is on the bottom right -> atlas for shadow maps. Every single shadow map used is stored there - and in this case it's totally 25 textures, all dynamically updated each frame.

Resolution is specified on per-light basis (although I do have some logic to determine resolution - based on number of light (& requried shadow maps) in scene, and some importance based on distance and light type ... it's not used in this example). So using shadow map atlas is definitely an option that gives you good enough results.

So how do I know if light has a shadow map bound (or 6 of them)? Simply storing 1 (or 6 for point lights) of integers pointing out which shadowID is used.

Each shadow atlas record is then just matrix, offsets and size, like:


struct __declspec(align(16)) ShadowAtlasRecord
{
	Engine::mat4 mMatrix;
	float mOffset[2];
	float mSize[2];
};

And I do have an array of these records passed into the shader.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

This topic is closed to new replies.

Advertisement