Prechádzať zdrojové kódy

switch method of enabling msaa to samples fied to be consistent textures samples api

Trevor Baron 7 rokov pred
rodič
commit
6030334cd5

+ 10 - 11
src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts

@@ -61,7 +61,6 @@
         private _depthOfFieldEnabled: boolean = false;
         private _depthOfFieldBlurLevel = DepthOfFieldEffectBlurLevel.Low;
         private _fxaaEnabled: boolean = false;
-        private _msaaEnabled: boolean = false;
         private _imageProcessingEnabled: boolean = true;
         private _defaultPipelineTextureType: number;
         private _bloomScale: number = 0.6;
@@ -266,21 +265,22 @@
             return this._fxaaEnabled;
         }
 
+        private _samples = 1;
         /**
-         * If the multisample anti-aliasing is enabled.
+         * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
          */
-        public set msaaEnabled(enabled: boolean) {
-            if (this._msaaEnabled === enabled) {
+        public set samples(sampleCount: number) {
+            if (this._samples === sampleCount) {
                 return;
             }
-            this._msaaEnabled = enabled;
+            this._samples = sampleCount;
 
             this._buildPipeline();
         }
 
         @serialize()
-        public get msaaEnabled(): boolean {
-            return this._msaaEnabled;
+        public get samples(): number {
+            return this._samples;
         }
 
         /**
@@ -506,10 +506,9 @@
                 this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
             }
 
-            if(this.msaaEnabled){
-                if(!this._enableMSAAOnFirstPostProcess()){
-                    BABYLON.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
-                }
+
+            if(!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1){
+                BABYLON.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
             }
         }
 

+ 2 - 2
src/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.ts

@@ -143,13 +143,13 @@ module BABYLON {
             this._renderEffectsForIsolatedPass = new Array<PostProcessRenderEffect>();
         }
 
-        protected _enableMSAAOnFirstPostProcess():boolean{
+        protected _enableMSAAOnFirstPostProcess(sampleCount: number):boolean{
             // Set samples of the very first post process to 4 to enable native anti-aliasing in browsers that support webGL 2.0 (See: https://github.com/BabylonJS/Babylon.js/issues/3754)
             var effectKeys = Object.keys(this._renderEffects);
             if(this.engine.webGLVersion >= 2 && effectKeys.length > 0){
                 var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
                 if(postProcesses){
-                    postProcesses[0].samples = 4;
+                    postProcesses[0].samples = sampleCount;
                     return true;
                 }
             }