Vertex Color = Material Emission at the Vertex +
Ambient Property at that Vertex +
The Ambient, Diffuse, and Specular Contributions
from all the Light Sources, properly Attentuated.
Below is a short description of each component of the lighting computation.
|
|
|
|
|
where light model is GL_LIGHT_MODEL_AMBIENT |
|
d = distance between light and vertex kc = GL_CONSTANT_ATTENUATION kl = GL_LINEAR_ATTENTUATION kq = GL_QUADRATIC_ATTENUATION If the light is directional, the attenuation valus is 1. |
|
0 if the vertex outside the cone of illumination max{v dot d, 0}GL_SPOT_EXPONENT v is unit vector from spotlight to vertex d is the spotlight direction |
|
|
|
L is unit vector from vertex to light n is the normal at the vertex |
|
if {L dot n} < 0, the specular component is zero. s is the sum of the two unit vectors that point between (1) the vertex and the light position (or direction) and (2) the vertex and the viewpoint (if GL_LIGHT_MODEL_LOCAL is true, else the vector is (0,0,1). |
Mathematically putting it together:
Below are images taken of renderings in SoftGL. The hardware images match per pixel. Special thanks to Kenny Hoff for some of the models. The deformable cube demo is very useful to show how much an improvement good hardware (full OpenGL support) performs compared to software, by changing the number of lights active. The second demo uses the tie fighter model and shows how well software performs when using three moving lights.
(click on images for larger versions)
Mouse | Used to Rotate |
Left Button | Locks mouse movements to controls |
, | Zoom In |
. | Zoom Out |
1-8 | Toggles Lights 1-8 On/Off |
q | Speeds up the Moving Lights |
w | Slows down the Moving Lights |
b | Toggle Backface Culling |
s | Toggle Smooth/Flat Color Interpolation |
l | Toggle Lighting |
d | Toggle Control Points (OpenGL only) |
p | Toggle Test Plane |
P | Toggle Deformable Cube |
\ | Toggle Moving/Stationary Lights |
` | Toggle Deforming/Stationary Cube |
; | Decrease Spotlight Exponent |
' | Increase Spotlight Exponent |
[ | Decrease Spotlight Cutoff |
] | Increase Spotlight Cutoff |
ESC | Exit |
SPACE | Toggle SoftGL vs OpenGL mode |
home |