瀏覽代碼

Merge pull request #2268 from Palmer-JC/master

Welcome to Wonderland
David Catuhe 8 年之前
父節點
當前提交
f0909d5388

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

@@ -60,6 +60,7 @@
 - Added a [HTML page](https://github.com/BabylonJS/Babylon.js/blob/master/Tools/Gulp/profiling.html) with embedded directions to improve the custom build process. ([jcpalmer](https://github.com/Palmer-JC))
 - Added glTF 2.0 loader with versioning support ([bghgary](https://github.com/bghgary), thanks to [BeardedGnome](https://github.com/BeardedGnome) for animation updates)
 - New `Motion Blur` effect added into `StandardRenderingPipeline` [Demo](http://www.babylonjs.com/Demos/MotionBlur/) ([Julien Moreau-Mathis](https://github.com/julien-moreau))
+- Allow the BlackAndWhite post process to adjust the degree in subsequent frames, for `Welcome to Wonderland`	types of animation ([jcpalmer](https://github.com/Palmer-JC))
  
 ### Bug fixes
 - Fixed a bug with spotlight direction ([deltakosh](https://github.com/deltakosh)) 

+ 8 - 1
src/PostProcess/babylon.blackAndWhitePostProcess.ts

@@ -1,7 +1,14 @@
 module BABYLON {
+
     export class BlackAndWhitePostProcess extends PostProcess {
+        public degree = 1;
+    
         constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
-            super(name, "blackAndWhite", null, null, options, camera, samplingMode, engine, reusable);
+            super(name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable);
+
+            this.onApplyObservable.add((effect: Effect) => {
+                effect.setFloat("degree", this.degree);
+            });
         }
     }
 } 

+ 5 - 2
src/Shaders/blackAndWhite.fragment.fx

@@ -1,9 +1,12 @@
 // Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
+uniform float degree;
 
 void main(void) 
 {
-	float luminance = dot(texture2D(textureSampler, vUV).rgb, vec3(0.3, 0.59, 0.11));
-	gl_FragColor = vec4(luminance, luminance, luminance, 1.0);
+	vec3 color = texture2D(textureSampler, vUV).rgb;
+	float luminance = dot(color, vec3(0.3, 0.59, 0.11));    
+	vec3 blackAndWhite = vec3(luminance, luminance, luminance);
+	gl_FragColor = vec4(color - ((color - blackAndWhite) * degree), 1.0);
 }