Benjamin Guignabert 5 anni fa
parent
commit
0ebeb53d72

File diff suppressed because it is too large
+ 1 - 1684
dist/preview release/babylon.ktx2Decoder.js


+ 56 - 0
src/Materials/prePassConfiguration.ts

@@ -0,0 +1,56 @@
+import { Matrix } from "../Maths/math.vector";
+import { Mesh } from "../Meshes/mesh";
+import { Scene } from "../scene";
+import { Effect } from "../Materials/effect";
+import { Constants } from "../Engines/constants";
+
+export class PrePassConfiguration {
+    public previousWorldMatrices: { [index: number]: Matrix } = {};
+    public previousViewProjection: Matrix;
+    public previousBones: { [index: number]: Float32Array } = {};
+
+    constructor() {
+
+    }
+
+    /**
+     * Add the required uniforms to the current list.
+     * @param uniforms defines the current uniform list.
+     */
+    public static AddUniforms(uniforms: string[]): void {
+        uniforms.push("previousWorld", "previousViewProjection");
+    }
+
+    /**
+     * Add the required samplers to the current list.
+     * @param samplers defines the current sampler list.
+     */
+    public static AddSamplers(samplers: string[]): void {
+        // pass
+    }
+
+    /**
+     * Binds the material data.
+     * @param effect defines theeffect to update
+     * @param scene defines the scene the material belongs to.
+     */
+    public bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void {
+        if (scene.prePassRenderer && scene.prePassRenderer.enabled) {
+            if (scene.prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE) !== -1) {
+                if (!this.previousWorldMatrices[mesh.uniqueId]) {
+                    this.previousWorldMatrices[mesh.uniqueId] = Matrix.Identity();
+                }
+
+                if (!this.previousViewProjection) {
+                    this.previousViewProjection = scene.getTransformMatrix();
+                }
+                
+                effect.setMatrix("previousWorld", this.previousWorldMatrices[mesh.uniqueId]);
+                effect.setMatrix("previousViewProjection", this.previousViewProjection);
+
+                this.previousWorldMatrices[mesh.uniqueId] = world.clone();
+                this.previousViewProjection = scene.getTransformMatrix().clone();
+            }
+        }
+    }
+}

+ 11 - 0
src/Shaders/ShadersInclude/prePassVertexDeclaration.fx

@@ -0,0 +1,11 @@
+#ifdef PREPASS
+#ifdef PREPASS_DEPTHNORMAL
+    varying vec3 vViewPos;
+#endif
+#ifdef PREPASS_VELOCITY
+    uniform mat4 previousWorld;
+    uniform mat4 previousViewProjection;
+    varying vec4 vCurrentPosition;
+    varying vec4 vPreviousPosition;
+#endif
+#endif