Sign in to follow this  
kiwijus

Deferred Lighting problem

Recommended Posts

kiwijus    99
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?

[code]
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;
[/code]

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

Share this post


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

Share this post


Link to post
Share on other sites
DarkChris    110
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:
[url="http://filmicgames.com"]Filmic Games[/url]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this