Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lighting question

Started by simotix Oct 7, 2008 at 2:26 PM 6 replies 1.2k views
Original Post
simotix
simotix
I have been doing multiple point lights for some time now and I would do it by turning on D3DBLENDOP_ADD. However, this presents a problem. If for the first pass, when I do not have blending on and it renders just green (for the green texture). Then I do the pass the second time, with blending with a red light. Well the are affected by the light actually looks yellow instead of red. Does anyone know how to get around this?
Evil Steve
Evil Steve
Quote:
Original post by simotix
I have been doing multiple point lights for some time now and I would do it by turning on D3DBLENDOP_ADD. However, this presents a problem. If for the first pass, when I do not have blending on and it renders just green (for the green texture). Then I do the pass the second time, with blending with a red light. Well the are affected by the light actually looks yellow instead of red. Does anyone know how to get around this?
Get around what? The laws of physics? [smile] Red plus green equals yellow with additive blending.

What effect are you trying to get? You can't shine a red light on a green surface and expect to get red back.
don
don
It should be black. You should sum the contribution of each of your lights. A light's contribution is determined by modulating (multiplying) the color of the light with the color of the surface. Look at the lighting formulas in the D3D docs for the old fixed function pipeline.


simotix
simotix
Quote:
Original post by Evil Steve
Quote:
Original post by simotix
I have been doing multiple point lights for some time now and I would do it by turning on D3DBLENDOP_ADD. However, this presents a problem. If for the first pass, when I do not have blending on and it renders just green (for the green texture). Then I do the pass the second time, with blending with a red light. Well the are affected by the light actually looks yellow instead of red. Does anyone know how to get around this?
Get around what? The laws of physics? [smile] Red plus green equals yellow with additive blending.

What effect are you trying to get? You can't shine a red light on a green surface and expect to get red back.


Is there a way to shine a red light on the green surface and get the red light rather then yellow?
MJP
MJP
Quote:
Original post by simotix
Is there a way to shine a red light on the green surface and get the red light rather then yellow?


You do get red light if you shine red light on a green surface. The problem is that you're blending this red color with the green color from the first pass, and you're getting yellow. If you only want the contribution from the red light, then only do that pass.
simotix
simotix
My problem is that during the first pass I render everything green with a texture, then the second pass I have a light on the surface with the color red. If I were to do no blend states on the second pass then areas without light would be black, when they should be green.
MJP
MJP
Why are you rendering the texture color in the first pass? Can't you just sample the texture color in your lighting pass?

Your problem is that you want to multiply your texture color with your light color, not add them. By using additive blending and putting down texture color then light color, you're adding them.
jollyjeffers
jollyjeffers
Quote:
Original post by MJP
Why are you rendering the texture color in the first pass? Can't you just sample the texture color in your lighting pass?
This seems to be the key point - by rendering the green texture in your first pass and using additive blending you're basically saying that your first pass is a pure-white ambient light.

You shouldn't be using the previous pass' results in the current pass if you want additive blending. As MJP says, you should (re-)sample the green texture in your subsequent lighting pass(es).

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.