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

Started by
4 comments, last by doomtr666 10 years, 2 months ago

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.

www.simulatedmedicine.com - medical simulation software

Looking to find experienced Ogre & shader developers/artists. PM me or contact through website with a contact email address if interested.

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.

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.


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.

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

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

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.

www.simulatedmedicine.com - medical simulation software

Looking to find experienced Ogre & shader developers/artists. PM me or contact through website with a contact email address if interested.

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 !

----

www.winthatwar.com

Download our latest demo here.

www.insaneunity.com

@InsaneUnity

@DTR666

This topic is closed to new replies.

Advertisement