< Zurück | Inhalt | Weiter >

10.1.1 Lighting equations

A mathematical equation (from the Java 3D Specification) determines the color of a pixel given the positions and colors of lights, Material properties of the pixel’s surface, normal vector for the surface, and position of the viewer. The lighting equation used in Java 3D is a simplification of the OpenGL lighting equation.


Note that


•Dot product


Note that if image, then diffi and speci are set to 0.


Note that for directional lights, atteni is set to 1.


Note that if the vertex is outside the spotlight cone, as defined by the cutoff angle, spoti is set to 0. For directional and point lights, spoti is set to 1.

The lighting equation is a subset of OpenGL in that the Java 3D ambient and directional lights are not attenuated and only ambient lights contribute to ambient lighting.

The parameters used in the lighting equation are:

E = Eye vector

Ma = Material ambient color Md = Material diffuse color Me = Material emissive color Ms = Material specular color N = Vertex normal

shin = Material shininess The per−light values are:

di = Distance from vertex to light

Di = Spotlight direction expi = Spotlight exponent Kci = Constant attenuation Kli = Linear attenuation Kqi = Quadratic attenuation

Li = Direction from vertex to light

Lci = Light color

Si = Specular half−vector = || (Li + E) ||

The basic principle of the lighting equations is fairly simple—if a surface is close to 90 degrees to a light ray, then the surface will be brightly lit. That is, large quantities of the light reaching the surface are absorbed by the surface and hence visible. The color used to brightly light the surface will be related to the color of the light as well as the color of the surface.