spotlight fixes: make more consistent across opengl, dx8, dx9

This commit is contained in:
David Rose 2007-03-30 23:23:27 +00:00
parent 018e01c326
commit cca375c2f3
3 changed files with 12 additions and 3 deletions

View File

@ -2306,7 +2306,11 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) {
alight.Position = *(D3DVECTOR *)pos.get_data();
alight.Range = __D3DLIGHT_RANGE_MAX;
alight.Falloff = 1.0f;
// Not sure why this factor of 60.0f is necessary; I determined it
// empirically. It seems to successfully approximate the OpenGL
// spotlight equation, at least for reasonably smallish FOV's.
alight.Falloff = light_obj->get_exponent() / 60.0f;
const LVecBase3f &att = light_obj->get_attenuation();
alight.Attenuation0 = att[0];

View File

@ -3456,7 +3456,12 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
alight.Direction = *(D3DVECTOR *)dir.get_data();
alight.Range = __D3DLIGHT_RANGE_MAX;
alight.Falloff = 1.0f;
// Not sure why this factor of 60.0f is necessary; I determined it
// empirically. It seems to successfully approximate the OpenGL
// spotlight equation, at least for reasonably smallish FOV's.
alight.Falloff = light_obj->get_exponent() / 60.0f;
alight.Theta = 0.0f;
alight.Phi = deg_2_rad(lens->get_hfov());

View File

@ -3989,7 +3989,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
GLP(Lightfv)(id, GL_SPOT_DIRECTION, dir.get_data());
GLP(Lightf)(id, GL_SPOT_EXPONENT, light_obj->get_exponent());
GLP(Lightf)(id, GL_SPOT_CUTOFF, lens->get_hfov());
GLP(Lightf)(id, GL_SPOT_CUTOFF, lens->get_hfov() * 0.5f);
const LVecBase3f &att = light_obj->get_attenuation();
GLP(Lightf)(id, GL_CONSTANT_ATTENUATION, att[0]);