Forráskód Böngészése

moving excluded meshes

Benjamin Guignabert 5 éve
szülő
commit
a1c8914d4b

+ 3 - 7
src/Materials/materialHelper.ts

@@ -10,7 +10,6 @@ import { VertexBuffer } from "../Meshes/buffer";
 import { Light } from "../Lights/light";
 import { Light } from "../Lights/light";
 import { Constants } from "../Engines/constants";
 import { Constants } from "../Engines/constants";
 import { PrePassConfiguration } from "../Materials/prePassConfiguration";
 import { PrePassConfiguration } from "../Materials/prePassConfiguration";
-import { MotionBlurConfiguration } from "../Rendering/motionBlurConfiguration";
 
 
 import { UniformBuffer } from "./uniformBuffer";
 import { UniformBuffer } from "./uniformBuffer";
 import { Effect, IEffectCreationOptions } from "./effect";
 import { Effect, IEffectCreationOptions } from "./effect";
@@ -207,12 +206,9 @@ export class MaterialHelper {
                 defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
                 defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
 
 
                 const prePassRenderer = mesh.getScene().prePassRenderer;
                 const prePassRenderer = mesh.getScene().prePassRenderer;
-                if (prePassRenderer) {
-                    const motionBlurConfiguration = prePassRenderer.getEffectConfiguration("motionBlur");
-                    if (motionBlurConfiguration) {
-                        const nonExcluded = (motionBlurConfiguration as MotionBlurConfiguration).excludedSkinnedMesh.indexOf(mesh) === -1;
-                        defines["BONES_VELOCITY_ENABLED"] = nonExcluded;
-                    }
+                if (prePassRenderer && prePassRenderer.enabled) {
+                    const nonExcluded = prePassRenderer.excludedSkinnedMesh.indexOf(mesh) === -1;
+                    defines["BONES_VELOCITY_ENABLED"] = nonExcluded;
                 }
                 }
             }
             }
         } else {
         } else {

+ 0 - 6
src/Rendering/motionBlurConfiguration.ts

@@ -1,7 +1,6 @@
 import { Constants } from "../Engines/constants";
 import { Constants } from "../Engines/constants";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { _DevTools } from '../Misc/devTools';
 import { _DevTools } from '../Misc/devTools';
-import { AbstractMesh } from '../Meshes/abstractMesh';
 
 
 /**
 /**
  * Contains all parameters needed for the prepass to perform
  * Contains all parameters needed for the prepass to perform
@@ -19,11 +18,6 @@ export class MotionBlurConfiguration implements PrePassEffectConfiguration {
     public name = "motionBlur";
     public name = "motionBlur";
 
 
     /**
     /**
-     * Stores skinned mesh excluded from the effect
-     */
-    public excludedSkinnedMesh: AbstractMesh[] = [];
-
-    /**
      * Textures that should be present in the MRT for this effect to work
      * Textures that should be present in the MRT for this effect to work
      */
      */
     public readonly texturesRequired: number[] = [
     public readonly texturesRequired: number[] = [

+ 8 - 1
src/Rendering/prePassRenderer.ts

@@ -9,6 +9,8 @@ import { _DevTools } from '../Misc/devTools';
 import { Color4 } from "../Maths/math.color";
 import { Color4 } from "../Maths/math.color";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { PrePassEffectConfiguration } from "./prePassEffectConfiguration";
 import { Nullable } from "../types";
 import { Nullable } from "../types";
+import { AbstractMesh } from '../Meshes/abstractMesh';
+
 /**
 /**
  * Renders a pre pass of the scene
  * Renders a pre pass of the scene
  * This means every mesh in the scene will be rendered to a render target texture
  * This means every mesh in the scene will be rendered to a render target texture
@@ -50,7 +52,12 @@ export class PrePassRenderer {
             type: Constants.PREPASS_ALBEDO_TEXTURE_TYPE,
             type: Constants.PREPASS_ALBEDO_TEXTURE_TYPE,
             format: Constants.TEXTURETYPE_UNSIGNED_INT,
             format: Constants.TEXTURETYPE_UNSIGNED_INT,
         },
         },
-];
+    ];
+
+    /**
+     * To save performance, we can excluded skinned meshes from the prepass
+     */
+    public excludedSkinnedMesh: AbstractMesh[] = [];
 
 
     private _textureIndices: number[] = [];
     private _textureIndices: number[] = [];