Deferred Lighting problem

Started by
2 comments, last by kiwijus 13 years ago
Hello, I'm attempting a deferred renderer and at the moment I'm trying to figure out multiple lights.

I render each light into it's own buffer, these are shown in dx1.png and dx2.png ( both different lights ). The lighting shader only does the diffuse and specular shading, no ambient light is calculated.

I then add the buffers together in a full screen quad as shown in dx3.png. What have I done wrong? How come the result is such a bright image?


float4 outputcolour = float4(0,0,0,0);
float4 L1 = Light1.Sample(linearSampler, input.t).xyzw;
float4 L2 = Light2.Sample(linearSampler, input.t).xyzw;
outputcolour = L1 + L2;


This is the HLSL code I use to add the buffers together.

I apologise in advance if it is blatantly obvious and I'm missing something simple!

Thanks,
Dave
Advertisement
While it may not be the only contributing issue, you should read up on gamma correct lighting (aka linear light blending). In most multipass additive lighting solutions it is the cause of overbrightening.

Here are some links to kick start you:
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html

http://www.gamasutra.com/blogs/DavidRosen/20100204/4322/GammaCorrect_Lighting.php

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=995B221D-6BBD-4731-AC82-D9524237D486&displaylang=en
As wanderingbort has already mentioned, you forgot to calculate your lighting in linear space. sRGB basically is a non-linear space that is used to save colors efficiently, especially when they are just using 8 bit's per color channel. Otherwise banding artifacts might occur. You could convert them into linear space by applying pow(x, 2.2). But it's better to configure your samplers and the rasterizer.
Also don't forget that you have to convert the resulting lighting back into gamma space (with e.g. pow(x, 1/2.2)).

John Hable's blog also contains important information about that topic:
Filmic Games

But that's not the problem. It won't get any darker. The thing is that it's HDR. It basically features colors that are brighter than what your screen is able to display. Now it's time to implement a tone mapper.
Thanks guys! I'll have a read through them sites and have a go at fixing it :)

This topic is closed to new replies.

Advertisement