소스 검색

Merge pull request #1071 from rgngl/lightDirectionBindingFix

RenderState: Transform scene light direction to view space.
Sean Paul Taylor 12 년 전
부모
커밋
740b89fd35
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  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);
     static Vector3 down(0, -1, 0);
     Scene* scene = _nodeBinding ? _nodeBinding->getScene() : NULL;
     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)
 void RenderState::bind(Pass* pass)