diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index c52b446ba9..7b48c0a467 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -2406,13 +2406,14 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { alight.Range = __D3DLIGHT_RANGE_MAX; - // 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; + // I determined this formular empirically. It seems to mostly + // approximate the OpenGL spotlight equation, for a reasonable range + // of values for FOV. + float fov = lens->get_hfov(); + alight.Falloff = light_obj->get_exponent() * (fov * fov * fov) / 1620000.0f; alight.Theta = 0.0f; - alight.Phi = deg_2_rad(lens->get_hfov()); + alight.Phi = deg_2_rad(fov); const LVecBase3f &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0]; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 5ab598fd11..29e292dda8 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3457,13 +3457,14 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { alight.Range = __D3DLIGHT_RANGE_MAX; - // 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; + // I determined this formular empirically. It seems to mostly + // approximate the OpenGL spotlight equation, for a reasonable range + // of values for FOV. + float fov = lens->get_hfov(); + alight.Falloff = light_obj->get_exponent() * (fov * fov * fov) / 1620000.0f; alight.Theta = 0.0f; - alight.Phi = deg_2_rad(lens->get_hfov()); + alight.Phi = deg_2_rad(fov); const LVecBase3f &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0];