Jump to content
  • Advertisement
Sign in to follow this  

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

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

If I have a red light and I have the following naff texture: Naff Texture Why is only the yellow lit up and the blue ignored? Only Yellow Lit 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 this post

Link to post
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 this post

Link to post
Share on other sites
Original post by Spa8nky
Excellent, 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.

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!