Sign in to follow this  
DAaaMan64

Deferred Rendering Problem

Recommended Posts

DAaaMan64    122
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.

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Hodgman    51226
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?

Share this post


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

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