Advertisement Jump to content
Sign in to follow this  

how to use ambient light

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

hellow, everyone !

I'm confused with the shader formula : 

finalColor = ambient + textureColor * diffuseLightColor ;

If there are no light in the scene, the finalColor is equal to ambient , then the object will be in single color.

I want to make the ambient as a darkness value, and the finalColor = ambient * textureColor .

Is the thought right ?

How to modify the code so that the code can adapt to both lighting environment and no-light environment ?

Edited by poigwym

Share this post

Link to post
Share on other sites

You was on the good road, never search complicated :

finalColor = (textureColor * ambientColor) + (textureColor * diffuseLightColor);

In other words, ambient is just a colorized diffuse texture added on the lighting or set as a start if multiple lights are added in the final color.

Edited by Alundra

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!