Advertisement Jump to content
Sign in to follow this  
JDX_John

OpenGL Standard emissive+ambient+diffuse+specular lighting model... how do texture and material settings combine?

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

The standard lighting used in OpenGL fixed-function (and I guess in D3D) basically boils down to:

color = material.emissive + material.ambient * light.ambient
      + material.diffuse * diffuseValue + material.specular * specularValue

Where diffuseValue and specularValue are calculated values.

 

But when you add a texture-map, how is this traditionally integrated i.e. how does it affect the emissive, ambient, diffuse and specular terms?

 

I assume emissive should not be modified. Should we replace material.ambient with material.ambient * textureValue and material.diffuse with material.diffuse * textureValue? Should specular BE affected by the texture map or not?

 

I'm aware there's probably a million valid ways it CAN be done. I'm mainly asking how the standard fixed-function pipeline does it.

Share this post


Link to post
Share on other sites
Advertisement

It just turns the specific value in question into something that can vary over the surface of a model instead of being uniform. Granted, ambient texture maps don't generally make sense, but it's just a question of scale and artistic intent.

Share this post


Link to post
Share on other sites


Granted, ambient texture maps don't generally make sense
Ambient lighting itself doesn't make sense wink.png

 

Ambient light is just diffuse light that comes from a magical "background"/bounce light, so both the "diffuse" and "ambient" results from this lighting model should be multiplied by the diffuse texture.

 

If present, the emissive term would be multiplied by an emissive map, and the specular term by a specular map.

Share this post


Link to post
Share on other sites

You could check this link on the d3d lighting model.

I'm not 100% sure if this is how the fixed pipeline does it though.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb147178(v=vs.85).aspx

 

That's a great link, but they nowhere mention how textures fit in. Only material and vertex colours are discussed :( Maybe material is synomous with texture, but I thought they were both supported simultaneously.

Share this post


Link to post
Share on other sites
Hi,
Looking in an old OpenGL 2.0 spec, it seems that active texture replace fragment color, chapter 3.8.15:
 
"This texture value is used along with the incoming fragment in computing the texture function
indicated by the currently bound texture environment. The result of this function
replaces the incoming fragment’s primary R, G, B, and A values"
 
If you look, in chapter 2.14.1, you have the complete lighting equations. 
 
Hope this helps !

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.

GameDev.net 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!