difference between ambient / diffuse material

hi everyone,


i’m asking myself if the “ambient” material value is actually necessary or “reasonable”
(i mean Ka for .obj model files)

the equation:
vec3 Intensity = Intensity(ambient) * Ka + Intensity(diffuse) * Kd + Intensity(specular) * Ks;

(Intensity(diffuse) and Intensity(specular) accumulated for all light sources)

now we have 3 different material constants, each describes how the surface interacts with light
Ka means what intensity (or color) will be reflected when ambient light shines on the surface
Kd means the same for diffuse light, but is there any difference between ambient and diffuse light ?
i think there isnt …

so what speaks against using Kd again for ambient light: (Ka = Kd)
vec3 Intensity = Kd * (Intensity(ambient) + Intensity(diffuse)) + Intensity(specular) * Ks;

regarding specular material value:
isnt reflected light almost ever completely “white” ? (Ks = vec3(1, 1, 1))
“white” means all RGB components of the intensity will be reflected completely

thanks for your advices!

Ambient and diffuse material colours are usually identical. The main reason why they might be different is that an object in shade may have its diffuse colour darkened (but with the same hue) to provide a crude simulation of shadowing.

Specular reflection is usually colourless. The most common exception is for metals such as copper or gold. Anodising or an iridescent oxide layer (a feature commonly associated with crystals of Bismuth) can also produce coloured specular reflections.

But most shiny, coloured materials consist of a shiny, colourless surface with coloured materials below the surface exhibiting diffuse reflection.

Ambient and diffuse light are not even remotely the same thing. If you want an in depth explanation, watch my HLSL video series. (You can probably skip the first video in the series where I talk about XNA and DirectX since you would be looking at this from an OGL perspective for GLSL. But otherwise I would go through the videos in order since they build on each other. My website has a GLSL shader that’s basically identical to the HLSL shader I have built by the end of the series. I would also be happy to repost that GLSL shader code if you wanted.)

I’ve never really liked the terms “ambient” and “diffuse”, but I’ve learned to live with them since they are industry standard terms. In real life, ambient light IS diffuse light. Ambient light is the light of the environment, most of which comes from reflected surfaces, which by definition is diffuse. Diffuse light is light that is not direct but has it’s path diverted from the source. Most lights would be too harsh if they were direct, so the bulb often has a coating that makes the light travel off in somewhat random directions. Often there will be some sort of translucent glass or something even after that that makes it more diffuse. The bottom line is that in real life the two terms are almost identical in meaning and the two terms really don’t do a very good job of describing the lighting in 3D graphics.

Now that we’ve gotten that out of the way, here’s what the terms mean in 3D graphics. Ambient light is the light I demonstrate in my “silhouette” video. It’s one color applied to everything. By itself, all it does is produce silhouettes of the objects presuming the background color is different from the ambient color. If they are the same, you won’t see anything. This type of lighting does not give you 3D any more than shadows are 3D. But it has a purpose, which is to fill in the shadow side of objects. (Note that nothing in this lighting model produces actual shadows which is another topic in and of itself.)

Diffuse light is light that comes from a large light source, like the sun. The light comes from the same direction no matter where you are in the scene. So, this doesn’t work for a street lamp at night, for example. But on a sunny day everything in the neighbourhood will be lit up from the same direction because the sun is such a huge light source that basically everything for many miles will be lit up the same way from it. I generally think of Diffuse light as sunlight because it simulates that rather well for outdoor lighting.

Diffuse light has a direction that it shines in represented by a normal. A surface that faces directly into that direction gets 100% of that light color. If it faces 90 degrees away or more, it will get no diffuse light and will presumably be pitch black. And if it faces some angle in between it will get a percentage of the diffuse light, which is primarily what makes objects look 3D. But shadows in the real world are almost never pitch black. They are usually lit up by reflection off surfaces such as walls or even the blue sky. That’s why shadows outdoors tend to have a blue tint; they are lit by the blue sky since the direct sunlight cannot reach those spots - but that doesn’t mean there is no light there.

I think this lighting model works best in simulating outdoor light. I set my direct light to be probably a pastel yellow to model sunlight and set the ambient light to a pastel blue to model refracted light from the blue sky. I then add them so that even the areas in diffuse light also get the ambient light. But the dark side of objects only get the ambient light.

When you add textures, this changes things a bit because you may light the object with the texture. I think the best way to go is to multiply the texture color with these other light sources so that the texture is given the color of the light sources. For example, if you multiply black (the dark side of the object) times any color including the texture color, you get black. Multiply white times that same color and you get the color rather than white. Multiply a color times the texture color and the texture color will be tinted.

So combined, the 3 give you the object’s surface color and simulate the sunlight and refracted blue sky. It works really well in simulating outdoor lighting. Make the light colors more grey for a stormy day.

But ambient light will not make things look 3D; by itself it only gives you a silhouette. The texture will help make it look 3D by itself. But without a texture (and somewhat even with the texture), the diffuse light is what makes objects look 3D. It’s also a big part of what makes bump/normal mapping work. It’s mostly the diffuse light that is affected by the normal map. (Normal maps give a direction for every pixel rather than for the entire surface which is then used in diffuse and specular lighting calculations.)

Reflected light in the real world is almost never white. But this depends on the situation of course. Is the light source it came from even white? If the object it’s reflecting off of has pigment it’s probably going to subtract part of the light unevenly meaning the light that comes off it will be colored. That’s why we perceive colored object as having a color.

White is a good place to start for specular. I’ve been making my specular highlights the color of the diffuse light source because “presumably” that’s where the specular light supposedly came from. And as I said, I often try to make my diffuse light “sun” colored rather than white. But I’m taking a 3D modeling course right now and one of the things that came up is the other day is specular maps. There you control the specular value for every pixel of the object individually. So, one part of the object can be shiny while the part next to it may be dull. A metal belt buckle on a leather belt might be an example. But sometimes artists use colored specular maps to give a separate color to the specular highlight than the surface color given by the texture. Sometimes they don’t; they just have a shininess value in the specular map but no color information.

thanks for your reply, i’ll take a look at your video tutorials
and thx for the info about the spec texture, first i thought these are the Ks values :doh: