Browse Source

Added dirty for image processing

David Catuhe 8 years ago
parent
commit
a25b14f105

File diff suppressed because it is too large
+ 1053 - 1050
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1053 - 1050
dist/preview release/babylon.module.d.ts


+ 2 - 1
dist/preview release/what's new.md

@@ -23,7 +23,8 @@
  - New `Cell Shading` material added into `Materials Library` [Demo](http://www.babylonjs.com/Demos/CellShading/) ([Julien Moreau-Mathis](https://github.com/julien-moreau))
  - New kernel based blur. [Demo](https://www.babylonjs-playground.com/#FBH4J7#1) ([deltakosh](https://github.com/deltakosh))
  - New highlights postprocess ([deltakosh](https://github.com/deltakosh))
- - New DefaultRenderingPipeline to enable image processing effect. [Demo](https://www.babylonjs-playground.com/#Y3C0HQ) ([deltakosh](https://github.com/deltakosh))
+ - New DefaultRenderingPipeline to enable image processing effect. [Demo](https://www.babylonjs-playground.com/#5XB8YT#1) ([deltakosh](https://github.com/deltakosh))
+ - New image processing postprocess. [Doc here](http://doc.babylonjs.com/tutorials/how_to_use_postprocesses#imageprocessing) ([deltakosh](https://github.com/deltakosh))
  - Spector.js New WebGL debugger: [more info here](http://spector.babylonjs.com) ([Sebastien Vandenberghe](https://github.com/sebavan))
  - New blur mode for mirrors. [Demo](https://www.babylonjs-playground.com/#9I6NX1) ([deltakosh](https://github.com/deltakosh)) 
 

+ 3 - 1
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -397,7 +397,7 @@
 
             // Attaches observer.
             this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(conf => {
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsImageProcessingDirty();
             });
         }
 
@@ -730,7 +730,9 @@
                 defines.PREMULTIPLYALPHA = this._premultiplyAlpha;
                 defines.ALPHABLEND = this.needAlphaBlending();
                 defines.ALPHAFRESNEL = this._useAlphaFresnel;
+            }
 
+            if (defines._areImageProcessingDirty) {
                 if (!this._imageProcessingConfiguration.isReady()) {
                     return false;
                 }

+ 12 - 0
src/Materials/babylon.material.ts

@@ -9,6 +9,7 @@
         public _areTexturesDirty = true;
         public _areFresnelDirty = true;
         public _areMiscDirty = true;    
+        public _areImageProcessingDirty = true;  
 
         public _normals = false;
         public _uvs = false;
@@ -27,6 +28,7 @@
             this._areFresnelDirty = false;
             this._areLightsDirty = false;
             this._areMiscDirty = false;
+            this._areImageProcessingDirty = false;
         }
 
         public markAsUnprocessed() {
@@ -39,9 +41,15 @@
             this._areLightsDirty = true;
             this._areFresnelDirty = true;
             this._areMiscDirty = true;
+            this._areImageProcessingDirty = true;
             this._isDirty = true;
         }
 
+        public markAsImageProcessingDirty() {
+            this._areImageProcessingDirty = true;
+            this._isDirty = true;
+        }        
+
         public markAsLightDirty() {
             this._areLightsDirty = true;
             this._isDirty = true;
@@ -575,6 +583,10 @@
             }
         }
 
+        protected _markAllSubMeshesAsImageProcessingDirty() {
+            this._markAllSubMeshesAsDirty(defines => defines.markAsImageProcessingDirty());
+        }        
+
         protected _markAllSubMeshesAsTexturesDirty() {
             this._markAllSubMeshesAsDirty(defines => defines.markAsTexturesDirty());
         }

+ 9 - 7
src/Materials/babylon.standardMaterial.ts

@@ -334,7 +334,7 @@ module BABYLON {
 
             // Attaches observer.
             this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(conf => {
-                this._markAllSubMeshesAsTexturesDirty();
+                this._markAllSubMeshesAsImageProcessingDirty();
             });
         }
 
@@ -671,12 +671,6 @@ module BABYLON {
                     defines.REFRACTION = false;
                 }
 
-                if (!this.imageProcessingConfiguration.isReady()) {
-                    return false;
-                }
-
-                this.imageProcessingConfiguration.prepareDefines(defines);
-
                 defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
 
                 defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
@@ -686,6 +680,14 @@ module BABYLON {
                 defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
             }
 
+            if (defines._areImageProcessingDirty) {
+                if (!this._imageProcessingConfiguration.isReady()) {
+                    return false;
+                }
+
+                this._imageProcessingConfiguration.prepareDefines(defines);
+            }
+
             if (defines._areFresnelDirty) {
                 if (StandardMaterial.FresnelEnabled) {
                     // Fresnel