瀏覽代碼

imageProcessing step 1

David Catuhe 8 年之前
父節點
當前提交
9a774578be

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


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


+ 13 - 10
src/PostProcess/babylon.imageProcessingPostProcess.ts

@@ -37,7 +37,7 @@
                 ColorCurves.Bind(this.colorCurves, effect);
 
                 // Vignette
-                let vignetteScaleY = 0;// TODO Math.tan(imageProcessing._scene.activeCamera.fov * 0.5);
+                let vignetteScaleY = this.getCamera().fov * 0.5 ;
                 let vignetteScaleX = vignetteScaleY * aspectRatio;
 
                 let vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
@@ -60,15 +60,18 @@
                 // Color transform settings
                 let hasColorGradingTexture = (this.colorGradingTexture != null) && this.colorGradingTexture.isReady();
                 effect.setBool('hasTextureColorTransform', hasColorGradingTexture);
-                //effect.setTexture('txColorTransform', hasColorGradingTexture ? this.colorGradingTexture : emptyTexture);
-                let textureSize = hasColorGradingTexture ? this.colorGradingTexture.getSize().height : 1.0;
-
-                effect.setFloat4("colorTransformSettings",
-                    (textureSize - 1) / textureSize, // textureScale
-                    0.5 / textureSize, // textureOffset
-                    textureSize, // textureSize
-                    hasColorGradingTexture ? this.colorGradingWeight : 0.0 // weight
-                );                
+
+                if (hasColorGradingTexture) {
+                    effect.setTexture('txColorTransform', this.colorGradingTexture);
+                    let textureSize = hasColorGradingTexture ? this.colorGradingTexture.getSize().height : 1.0;
+
+                    effect.setFloat4("colorTransformSettings",
+                        (textureSize - 1) / textureSize, // textureScale
+                        0.5 / textureSize, // textureOffset
+                        textureSize, // textureSize
+                        hasColorGradingTexture ? this.colorGradingWeight : 0.0 // weight
+                    );                
+                }
             };
         }
 

+ 4 - 0
src/PostProcess/babylon.postProcess.ts

@@ -112,6 +112,10 @@
             return this._textures.data[this._currentRenderTextureInd];
         }      
 
+        public getCamera(): Camera {
+            return this._camera;
+        }
+
         constructor(public name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines?: string, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
             if (camera != null) {
                 this._camera = camera;

+ 1 - 1
src/Shaders/imageProcessing.fragment.fx

@@ -118,7 +118,7 @@ void main(void)
 {
 	vec4 result = texture2D(textureSampler, vUV);
 
-	vec2 viewportXY = texelCoord * 2.0 - 1.0;
+	vec2 viewportXY = vUV * 2.0 - 1.0;
 	result = applyImageProcessing(result, viewportXY);
 
 	gl_FragColor = result;