Przeglądaj źródła

Merge pull request #1071 from rgngl/lightDirectionBindingFix

RenderState: Transform scene light direction to view space.
Sean Paul Taylor 12 lat temu
rodzic
commit
740b89fd35
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      gameplay/src/RenderState.cpp

+ 7 - 1
gameplay/src/RenderState.cpp

@@ -400,7 +400,13 @@ const Vector3& RenderState::autoBindingGetLightDirection() const
 {
     static Vector3 down(0, -1, 0);
     Scene* scene = _nodeBinding ? _nodeBinding->getScene() : NULL;
-    return scene ? scene->getLightDirection() : down;
+    if (scene) {
+        static Vector3 lightDirection;
+        lightDirection.set(scene->getLightDirection());
+        _nodeBinding->getViewMatrix().transformVector(&lightDirection);
+        return lightDirection;
+    }
+    return down;
 }
 
 void RenderState::bind(Pass* pass)