Ian: Check out my update on Jan. 30, 2012
here.
My lighting equation is definitely wrong. I basically do this (ignoring specular and spot lighting):
- Code: Select all
light_intensity = polygon_modulation_color * (sun_factor * viewport_sun_intensity + viewport_ambient_intensity)
final_fragment_color = fragment_color * light_intensity
Where
polygon_modulation_color is the RGB value extracted from the polygon header,
sun_factor is the projection of the sun vector on the vertex normal (i.e., dot product of the light direction and normal), and
fragment_color is either a raw texel color value or the polygon color for un-textured polygons.
Note that
OpenGL's lighting equation is
additive to the "material emission" component, which in our case corresponds to
polygon_modulation_color:
- Code: Select all
light_intensity = (material emission) + (global ambient)*(material ambient) + [(light ambient)*(material ambient) + (max{L.N, 0})*(light diffuse)*(material diffuse) + (max{H.N,0}) *(light specular)*(material specular) ]
This is something I've long wanted to investigate and wish I had time. I thought I had tried something similar to the GL equation but it's worth a re-visit. I just realized that by making the lighting additive to the underlying polygon color, the illumination of the castle and bridge battlements in Scud Race's expert course would likely be fixed (it currently looks completely black on the initial approach because the sun light component drops to 0 there).