Calculating ambient light.

This is a discussion on Calculating ambient light. within the Game Programming forums, part of the General Programming Boards category; I had an idea a little while ago for calculateing the ambient lighting term, but i'm not sure how well ...

  1. #1
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070

    Calculating ambient light.

    I had an idea a little while ago for calculateing the ambient lighting term, but i'm not sure how well it would work in practice.

    Suppose in my lighting system, i'm rendering the scene to a texture every frame to use HDR rendering, or some other technique that uses video post-processing.

    Now, up untill now i've been just using a static value (usually zero) for the ambient term. But , if I were to get the average color from my scene texture, would this not be a more accurate ambient light value? To me (in theory of course), it sounds like using the average screen color as the ambient term would be able to emulate global indirect lighting.

    This is probably not an original idea, but I haven't heard of it.
    Is there any chance it could work, or does this idea break down when put into practice?
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    It breaks down because then ambient light is dependent on other light sources in the scene since they will add light to it. This means as your light's hit objects and thus lights surfaces up, this increases your average value, but it increases it for every object in the scene - no matter where it is.

    Take two objects and stick a wall between them. Shine a light on the right hand object and you will unfortunately illuminate the left hand object as well since your ambient light for the entire scene has increased. It will increase because the surface of the right hand object has been lit. When you go to average the colors, these will increase the overall average even if the other object is totally obscured from the light hitting the right object. It wouldn't look right.

    Ambient light is fine at being a static value. I normally choose something like 40 to 100 depending on the environment. I tried to use 0 in my space game and wow....everything looked pitch black when you moved away from the sun. Probably realistic, but not very fun.
    Last edited by VirtualAce; 06-06-2006 at 06:16 AM.

  3. #3
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    >>This means as your light's hit objects and thus lights surfaces up, this increases your average value, but it increases it for every object in the scene - no matter where it is.

    Wouldn't some type of shadowing method solve this?
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    But your ambient lighting calculations would nullify the shadowing. Essentially your ambient light calculation would be almost like doing a gamma ramp on the screen. It would brighten more and more with each light source which is how ambient light works, but it does not work like that in a world-based lighting model.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL example cube is black, white, grey only
    By edwardtisdale in forum Windows Programming
    Replies: 7
    Last Post: 09-22-2007, 02:37 PM
  2. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  3. geometry won't display!?
    By psychopath in forum Game Programming
    Replies: 17
    Last Post: 09-21-2004, 10:10 AM
  4. How many forums members to change a lightbulb.
    By adrianxw in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 01-01-2004, 07:31 PM
  5. A Common Scientific Belief
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 03-29-2002, 04:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21