Browse Source

add ability to set output texture scale of a post process

Trevor Baron 7 năm trước cách đây
mục cha
commit
afe8f81f20

+ 2 - 1
src/PostProcess/babylon.bloomEffect.ts

@@ -59,10 +59,11 @@ module BABYLON {
             this._blurY = new BlurPostProcess("vertical blur", new Vector2(0, 1.0), 10.0, bloomScale, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, undefined, blockCompilation);
             this._blurY.alwaysForcePOT = true;
             this._blurY.autoClear = false;
+            this._blurY._outputTextureScale = bloomScale;
 
             this.kernel = bloomKernel;
 
-            this._effects = [this._downscale, this._blurY, this._blurX];
+            this._effects = [this._downscale, this._blurX, this._blurY];
 
             if(performMerge){
                 this._merge = new DefaultPipelineMergeMergePostProcess("defaultPipelineMerge", {originalFromInput: this._blurX, bloom: {blurred: this._blurY, weight: 0}}, 1, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType, blockCompilation);

+ 5 - 2
src/PostProcess/babylon.postProcess.ts

@@ -19,7 +19,10 @@
         * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
         */
         public _outputTexture: Nullable<InternalTexture> = null;
-
+        /**
+        * Internal, if set, this will override the next postprocess in the chain's input texture's width an height
+        */
+        public _outputTextureScale:number = 0;
         /**
         * Sampling mode used by the shader
         * See https://doc.babylonjs.com/classes/3.1/texture
@@ -73,7 +76,7 @@
         private _camera: Camera;
         private _scene: Scene;
         private _engine: Engine;
-        private _options: number | PostProcessOptions;
+        public _options: number | PostProcessOptions;
         private _reusable = false;
         private _textureType: number;
         /**

+ 3 - 0
src/PostProcess/babylon.postProcessManager.ts

@@ -150,6 +150,9 @@
                 var pp = postProcesses[index];
 
                 if (index < len - 1) {
+                    if(pp._outputTextureScale){
+                        postProcesses[index + 1]._options = pp._outputTextureScale;
+                    }
                     pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
                 } else {
                     if (targetTexture) {