|
@@ -1,10 +1,11 @@
|
|
import { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
import { UniformBuffer } from "../../Materials/uniformBuffer";
|
|
import { Matrix } from "../../Maths/math.vector";
|
|
import { Matrix } from "../../Maths/math.vector";
|
|
|
|
+import { Mesh } from "../../Meshes/mesh";
|
|
import { Scene } from "../../scene";
|
|
import { Scene } from "../../scene";
|
|
import { PrePassRenderer } from "../../Rendering/prePassRenderer";
|
|
import { PrePassRenderer } from "../../Rendering/prePassRenderer";
|
|
|
|
|
|
export class PBRAdditionnalPrePassConfiguration {
|
|
export class PBRAdditionnalPrePassConfiguration {
|
|
- public previousWorld: Matrix;
|
|
|
|
|
|
+ public previousWorldMatrices: { [index: number]: Matrix } = {};
|
|
public previousViewProjection: Matrix;
|
|
public previousViewProjection: Matrix;
|
|
|
|
|
|
constructor() {
|
|
constructor() {
|
|
@@ -45,18 +46,21 @@ export class PBRAdditionnalPrePassConfiguration {
|
|
* @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
|
|
* @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
|
|
* @param realTimeFiltering defines whether the textures should be filtered on the fly.
|
|
* @param realTimeFiltering defines whether the textures should be filtered on the fly.
|
|
*/
|
|
*/
|
|
- public bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, world: Matrix, isFrozen: boolean): void {
|
|
|
|
|
|
+ public bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void {
|
|
|
|
|
|
if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
|
|
if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
|
|
if (scene.prePassRenderer && scene.prePassRenderer.enabled) {
|
|
if (scene.prePassRenderer && scene.prePassRenderer.enabled) {
|
|
// TODO : cache for better performance
|
|
// TODO : cache for better performance
|
|
if (scene.prePassRenderer.getIndex(PrePassRenderer.VELOCITY_TEXTURE_TYPE) !== -1) {
|
|
if (scene.prePassRenderer.getIndex(PrePassRenderer.VELOCITY_TEXTURE_TYPE) !== -1) {
|
|
- if (this.previousWorld) {
|
|
|
|
- uniformBuffer.updateMatrix("previousWorld", this.previousWorld);
|
|
|
|
- uniformBuffer.updateMatrix("previousViewProjection", this.previousViewProjection);
|
|
|
|
|
|
+ if (!this.previousWorldMatrices[mesh.uniqueId]) {
|
|
|
|
+ this.previousWorldMatrices[mesh.uniqueId] = Matrix.Identity();
|
|
|
|
+ // TODO move out in own test
|
|
|
|
+ this.previousViewProjection = scene.getTransformMatrix();
|
|
}
|
|
}
|
|
-
|
|
|
|
- this.previousWorld = world.clone();
|
|
|
|
|
|
+ uniformBuffer.updateMatrix("previousWorld", this.previousWorldMatrices[mesh.uniqueId]);
|
|
|
|
+ uniformBuffer.updateMatrix("previousViewProjection", this.previousViewProjection);
|
|
|
|
+
|
|
|
|
+ this.previousWorldMatrices[mesh.uniqueId] = world.clone();
|
|
this.previousViewProjection = scene.getTransformMatrix().clone();
|
|
this.previousViewProjection = scene.getTransformMatrix().clone();
|
|
}
|
|
}
|
|
|
|
|