瀏覽代碼

Simplify code for scene ubo in shadow generator

Popov72 4 年之前
父節點
當前提交
c8d2a1b939
共有 1 個文件被更改,包括 3 次插入9 次删除
  1. 3 9
      src/Lights/Shadows/shadowGenerator.ts

+ 3 - 9
src/Lights/Shadows/shadowGenerator.ts

@@ -914,19 +914,13 @@ export class ShadowGenerator implements IShadowGenerator {
             if (this._filter === ShadowGenerator.FILTER_PCF) {
                 engine.setColorWrite(false);
             }
-            if (engine.supportsUniformBuffers) {
-                const sceneUBO = this._scene._getNewSceneUniformBuffer(); // get a new scene ubo for the shadow pass
-                sceneUBO.updateMatrix("viewProjection", this.getTransformMatrix());
-                sceneUBO.updateMatrix("view", this._viewMatrix);
-                sceneUBO.update();
-            }
+            this.getTransformMatrix(); // generate the view/projection matrix
+            this._scene.setTransformMatrix(this._viewMatrix, this._projectionMatrix);
         });
 
         // Blur if required afer render.
         this._shadowMap.onAfterUnbindObservable.add(() => {
-            if (engine.supportsUniformBuffers) {
-                this._scene.updateTransformMatrix(); // reset the view/projection matrices
-            }
+            this._scene.updateTransformMatrix(); // restore the view/projection matrices of the active camera
 
             if (this._filter === ShadowGenerator.FILTER_PCF) {
                 engine.setColorWrite(true);