3
\$\begingroup\$

Are ambient, diffuse and specular properties of light or material?

I am doing ray casting in OpenGL, I've managed to create lit sphere using formula

I = L Ka + L Kd (n . l) + L Ks (r . v)^n

but I entered values manually, now I'd like to create objects for light and sphere, but I don't know which of these properties (Ka-ambient, Kd-diffuse, Ks-specular) should be within the light object and which within the material (sphere) object

\$\endgroup\$
3
\$\begingroup\$

They are properties of both lights and materials. Typically, materials have a diffuse color and a specular color. Lights just have a light color. When shading a surface, you would multiply the light color componentwise with the material's diffuse and specular colors to arrive at the Kd and Ks values for that equation.

Thus you could have various colors of materials, illuminated by various colors of lights, and have them combine appropriately.

As for ambient, it's not really a separate material property, more like a separate light source that fills the world and applies to every surface. It's a very simple stand-in for global illumination (multi-bounce light). Like other light sources, it has a color. Technically the ambient light should produce both diffuse and specular reflections on the surface, just like any other light. In practice, with this kind of very simple lighting model, you can often just use the material diffuse color and multiply it by the global ambient light color to get Ka in the lighting equation.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ so should ambient colour part be the same for every object within the scene? Is that correct? \$\endgroup\$ – Riko Nov 14 '13 at 18:43
  • \$\begingroup\$ @Jozi The ambient light color will be a constant, but materials can optionally have an ambient color to describe how they appear individually in ambient light. As Nathan pointed out, it's reasonable to just use the diffuse color though, in a simplified lighting model. \$\endgroup\$ – kevintodisco Nov 14 '13 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.