Advertisement Jump to content
Sign in to follow this  

Deferred Lighting problem

This topic is 2842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!


Share this post

Link to post
Share on other sites
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:

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!