瀏覽代碼

RenderState: Transform scene light direction to view space.

Üstün Ergenoglu 12 年之前
父節點
當前提交
e217ee42ae
共有 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)