# Why is the following texture colour not lit with additive blending?

This topic is 3173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If I have a red light and I have the following naff texture: Why is only the yellow lit up and the blue ignored? This doesn't seem correct? I am combining my light and textures with the following:
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
// FinalColour = DiffuseColour * DiffuseLight + SpecularLight

float3 DiffuseColour = tex2D(ColourSampler, input.TexCoord).rgb;

float4 light = tex2D(LightSampler, input.TexCoord);
float3 DiffuseLight = light.rgb;
float SpecularLight = light.a;

return float4((DiffuseColour * DiffuseLight + SpecularLight), 1);
}


I've no idea what's going wrong, can someone please help?

##### Share on other sites
When multiplying blue with red light, you get black. Yellow is (1, 1, 0), and blue is (0, 0, 1).
(1, 1, 0) * (1, 0, 0) = (1, 0, 0) = red
(0, 0, 1) * (1, 0, 0) = (0, 0, 0) = black

When there is only red light hitting a surface that only reflects blue light, there is no light that will be reflected and visible.

##### Share on other sites
Excellent, thank you.

How would I add ambient light to the mix then to make sure that the area is evenly lit?

##### Share on other sites
Quote:
 Original post by Spa8nkyExcellent, thank you.How would I add ambient light to the mix then to make sure that the area is evenly lit?

In reality you would be hard-pressed to find a material that is completely red, blue, green, or black. The same goes for light sources.

I'm not sure what you mean by evenly lit, but I would make sure that I don't use textures where any pixel component (R,G,B) is completely black. I wouldn't use a light that was completely one color either unless, I wanted some sort of special effect.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 10
• 12
• 20
• 12
• 13
• ### Forum Statistics

• Total Topics
632148
• Total Posts
3004450

×