Browse Source

normalize light direction

David Rose 17 years ago
parent
commit
9bc056eac3
1 changed files with 2 additions and 0 deletions
  1. 2 0
      panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

+ 2 - 0
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1698,6 +1698,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) {
   CPT(TransformState) net_transform = render_transform->compose(transform);
   CPT(TransformState) net_transform = render_transform->compose(transform);
 
 
   LVector3f dir = light_obj->get_direction() * net_transform->get_mat();
   LVector3f dir = light_obj->get_direction() * net_transform->get_mat();
+  dir.normalize();
   gl_light->position.X = -dir[0];
   gl_light->position.X = -dir[0];
   gl_light->position.Y = -dir[1];
   gl_light->position.Y = -dir[1];
   gl_light->position.Z = -dir[2];
   gl_light->position.Z = -dir[2];
@@ -1754,6 +1755,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
   const LMatrix4f &light_mat = net_transform->get_mat();
   const LMatrix4f &light_mat = net_transform->get_mat();
   LPoint3f pos = lens->get_nodal_point() * light_mat;
   LPoint3f pos = lens->get_nodal_point() * light_mat;
   LVector3f dir = lens->get_view_vector() * light_mat;
   LVector3f dir = lens->get_view_vector() * light_mat;
+  dir.normalize();
 
 
   gl_light->position.X = pos[0];
   gl_light->position.X = pos[0];
   gl_light->position.Y = pos[1];
   gl_light->position.Y = pos[1];