Selaa lähdekoodia

move fxaa before bloom

Trevor Baron 7 vuotta sitten
vanhempi
commit
7859ceabe7

+ 14 - 6
src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts

@@ -384,6 +384,7 @@
         private _hasCleared = false;
         private _prevPostProcess:Nullable<PostProcess> = null;
         private _prevPrevPostProcess:Nullable<PostProcess> = null;
+        private _firstPostProcess:Nullable<PostProcess> = null;
 
         private _setAutoClearAndTextureSharing(postProcess:PostProcess, skipTextureSharing = false){
             if(this._hasCleared){
@@ -394,6 +395,11 @@
                 this._hasCleared = true;
             }
 
+            if(!this._firstPostProcess){
+                this._firstPostProcess = postProcess;
+                skipTextureSharing = true;
+            }
+
             if(!skipTextureSharing){
                 if(this._prevPrevPostProcess){
                     postProcess.shareOutputWith(this._prevPrevPostProcess);
@@ -426,9 +432,16 @@
             this._prevPostProcess = null;
             this._prevPrevPostProcess = null;
             this._hasCleared = false;
+            this._firstPostProcess = null;
 
             var mergeOptions = new DefaultPipelineMergePostProcessOptions();
 
+            if (this.fxaaEnabled) {
+                this.fxaa = new FxaaPostProcess("fxaa", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                this.addEffect(new PostProcessRenderEffect(engine, this.FxaaPostProcessId, () => { return this.fxaa; }, true));
+                this._setAutoClearAndTextureSharing(this.fxaa);
+            }
+
             if (this.sharpenEnabled) {
                 if(!this.sharpen.isReady()){
                     this.sharpen.updateEffect();
@@ -459,6 +472,7 @@
                 if(!mergeOptions.originalFromInput){
                     mergeOptions.originalFromInput=this.bloom._effects[0];
                 }
+                this.bloom._downscale._inputPostProcess = this._firstPostProcess;
                 this.addEffect(this.bloom);
                 this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
             }
@@ -470,12 +484,6 @@
                 this._setAutoClearAndTextureSharing(this._defaultPipelineMerge, true);
             }
 
-            if (this.fxaaEnabled) {
-                this.fxaa = new FxaaPostProcess("fxaa", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
-                this.addEffect(new PostProcessRenderEffect(engine, this.FxaaPostProcessId, () => { return this.fxaa; }, true));
-                this._setAutoClearAndTextureSharing(this.fxaa);
-            }
-
             if (this._imageProcessingEnabled) {
                 this.imageProcessing = new ImageProcessingPostProcess("imageProcessing", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 if (this._hdr) {

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

@@ -8,8 +8,10 @@ module BABYLON {
          */
         public _effects: Array<PostProcess> = [];
 
-
-        private _downscale:ExtractHighlightsPostProcess;
+        /**
+         * Internal
+         */
+        public _downscale:ExtractHighlightsPostProcess;
         private _blurX:BlurPostProcess;
         private _blurY:BlurPostProcess;
         private _upscale:PassPostProcess;

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

@@ -7,9 +7,13 @@ module BABYLON {
          * The luminance threshold, pixels below this value will be set to black.
          */
         public threshold = 0.9;
+        public _inputPostProcess:Nullable<PostProcess> = null;
         constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
             super(name, "extractHighlights", ["threshold"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
             this.onApplyObservable.add((effect: Effect) => {
+                if(this._inputPostProcess){
+                    effect.setTextureFromPostProcess("textureSampler", this._inputPostProcess);
+                }
                 effect.setFloat('threshold', this.threshold);
             })
         }