Deferred Rendering Problem

Started by
6 comments, last by NiGoea 13 years, 4 months ago
So currently in my Material Pass (final pass) I am doing:

finalColor = colorTex * lightTex + specularLight.

However, this is a problem. If I put 10 point lights in the same spot it will make the lightTex values in that spot 1.0 as expected. Thus the ultimate final color is:

finalColor = colorTex * 1.0 + specularLight.

So that means that the maximum brightness I can get to is the colorTex value. Unless, I am supposed to rely completely on specularLight to increase brightness.

Do I understand that correctly? What am I doing wrong?

Thanks.
Advertisement
When you do your lighting pass, make sure to turn additive blending on, this will add the values together that go to your back buffer, and you can get your correctly blending values.
Make sure to turn it off after you are done though because blending does cost additional work to be done.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
I believe I already do this.

So if I have additive blending on (BlendOp: Add, SrcBlend: One, DestBlend: One) and I render a ton of a point lights in one spot the value will go to 1.0 in the light tex correct? That still limits the final color to the value in colorTex. It should be brighter than colorTex in realistic lighting.
addative blending means that each of the colors output to the backbuffer are added onto one another. For example:

Light1 outputs (.5, .5, .7);
Light2 outputs (.5, .5, .7);
the color will now be (1, 1, 1.4);

But, remember that values are clamped to the backbuffer in the [0,1] range. So 1 is the higghest you can get

Yeah, those blend settings are correct.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
Okay I understand that cool.

So that means the only way to brighten my lights beyond the color of the pixel I'm rendering to I will need to use the specularLight in the equation:

finalColor = colorTex * 1.0 + specularLight.

I'm assuming people who use deferred rendering do this some other way.
Quote:Original post by smasherprog
But, remember that values are clamped to the backbuffer in the [0,1] range. So 1 is the higghest you can get
This is true for 8 bit textures.

If you're collecting lighting in a texture though, you really do not want it being clamped in the [0,1] range! Ideally, you would simply use a FP16 texture.

that's not possible, then before writing out a lighting value, you divide it by the brightest value you want to have. Then when reading the lighting texture, you multiply by this value -- this lets you store [0,n] range in any texture, but results in banding artifacts.
Also, if you can't use FP16, you could try to use a 10 bit texture (R10G10B10A2), which will result in much less banding than an 8 bit one.


Deferred rendering doesn't usually involve a lighting buffer though... Are you implementing light-pre-pass?
Maybe I'm stuck somewhere in between. I have:

I have Color, Light, Depth, Normal textures +1 for effects.

The light texture only has light rendered to it.
Quote:Original post by DAaaMan64


So that means that the maximum brightness I can get to is the colorTex value. Unless, I am supposed to rely completely on specularLight to increase brightness.


If I understood correctly, you talk about the problem that it's impossible to obtain very bright colors (very bright textures) in the composed frame.
You can overcome it by changing color format (LUV maybe), or by using a scaling factor, which is a very simple solution (yet not perfect) that I'm currently using.
You divide by K when updating the color buffer, and multyply by K in the pixel shader in order to retrieve the corret light amount. Obviously, K > 1.

hope this helps

This topic is closed to new replies.

Advertisement