Jump to content
  • Advertisement
Sign in to follow this  

multi-pass lighting

This topic is 3124 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

Im a little confused as to how this works. All the information I've gotten from google says that you add the results of each pass to the back buffer, using blending of 1. so .. pixel = (1 * ExistingBufferPixel) + (1 * NewPixelColour); And im wondering why the result is added. As after a few passess isnt this going to blow out the pixel to fully white? for example say i had pass 1, pixel out = 120, 45, 20 pass 2, pixel out = 20, 85, 120 pass 3, pixel out = 220, 135, 240 which when you add them all up, its going to be +255 for each channel, due to you never having negative numbers. I thought that when you want to combiine the result of lots of lights you would mulitply them, not add them, as multiplying wont blow out to white. And my other question is regarding shadow mapping using the multi-pass approach. Lets say that on the first pass, some pixel is calculated as being in shadow, so we darken it. But then in the next pass, with a different light, it turns out to be lit, depending on how much you darkened it, arent you going to have lost some data there? so that when you light it again, its not going to look right.

Share this post


Link to post
Share on other sites
Advertisement
It's supposed to max out to white. If you shine many different lights on the same spot, it's going to get brighter and brighter. You can try this in real life, if you have flashlights that are red green and blue. If you shine all three on the same spot, you will see white light.

You should never darken spots in shadow, just avoid adding light there. Light is never ever subtracted, only added. If a point is in shadow from light 1, no light will be added there, and it will look darker. So if a point is in shadow only for pass 3, you will end up with (pass1 + pass2).

Share this post


Link to post
Share on other sites
Quote:
Original post by hick18
Im a little confused as to how this works. All the information I've gotten from google says that you add the results of each pass to the back buffer, using blending of 1.

so ..

pixel = (1 * ExistingBufferPixel) + (1 * NewPixelColour);

And im wondering why the result is added.


That's how lighting works. If you shine two lights on a surface, the correct result is to add the contribution of each light


Quote:
Original post by hick18
As after a few passess isnt this going to blow out the pixel to fully white?


If your lights are bright enough, then yes. Some people solve this by accumulating lighting into an HDR format. Otherwise, just be mindful of the intensity of your lights and tweak until stuff looks good.


Quote:
Original post by hick18
And my other question is regarding shadow mapping using the multi-pass approach. Lets say that on the first pass, some pixel is calculated as being in shadow, so we darken it.


You don't "darken" pixels that are in shadow to a particular light, you just don't add that light's contribution to the scene.

Quote:
Original post by hick18
But then in the next pass, with a different light, it turns out to be lit, depending on how much you darkened it, arent you going to have lost some data there? so that when you light it again, its not going to look right.


You have some assumption that you calculate some value and then darken/lighten it for each light that affects the surface. This isn't how it works and won't give you correct results (you can try it if you like to see why). You take the color texture, normal, etc and calculate the full lighting equation for each light, and accumulate the results to the final result.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!