Explorar o código

Fix pp filtering

David Catuhe %!s(int64=5) %!d(string=hai) anos
pai
achega
dfe7d25fa0

+ 13 - 10
src/Engines/constants.ts

@@ -186,18 +186,21 @@ export class Constants {
     /** FLOAT_32_UNSIGNED_INT_24_8_REV */
     public static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
 
-    /** nearest is mag = nearest and min = nearest and mip = nearest */
+    /** nearest is mag = nearest and min = nearest and no mip */
     public static readonly TEXTURE_NEAREST_SAMPLINGMODE = 1;
-    /** Bilinear is mag = linear and min = linear and mip = nearest */
+    /** mag = nearest and min = nearest and mip = none */
+    public static readonly TEXTURE_NEAREST_NEAREST = 1;
+    
+    /** Bilinear is mag = linear and min = linear and no mip */
     public static readonly TEXTURE_BILINEAR_SAMPLINGMODE = 2;
+    /** mag = linear and min = linear and mip = none */
+    public static readonly TEXTURE_LINEAR_LINEAR = 2;
+
     /** Trilinear is mag = linear and min = linear and mip = linear */
     public static readonly TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
-    /** nearest is mag = nearest and min = nearest and mip = linear */
-    public static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
-    /** Bilinear is mag = linear and min = linear and mip = nearest */
-    public static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
     /** Trilinear is mag = linear and min = linear and mip = linear */
     public static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
+    
     /** mag = nearest and min = nearest and mip = nearest */
     public static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
     /** mag = nearest and min = linear and mip = nearest */
@@ -206,14 +209,14 @@ export class Constants {
     public static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
     /** mag = nearest and min = linear and mip = none */
     public static readonly TEXTURE_NEAREST_LINEAR = 7;
-    /** mag = nearest and min = nearest and mip = none */
-    public static readonly TEXTURE_NEAREST_NEAREST = 8;
+    /** nearest is mag = nearest and min = nearest and mip = linear */
+    public static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8;
     /** mag = linear and min = nearest and mip = nearest */
     public static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
     /** mag = linear and min = nearest and mip = linear */
     public static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
-    /** mag = linear and min = linear and mip = none */
-    public static readonly TEXTURE_LINEAR_LINEAR = 11;
+    /** Bilinear is mag = linear and min = linear and mip = nearest */
+    public static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11;
     /** mag = linear and min = nearest and mip = none */
     public static readonly TEXTURE_LINEAR_NEAREST = 12;
 

+ 7 - 7
src/PostProcesses/postProcess.ts

@@ -453,6 +453,12 @@ export class PostProcess {
         var desiredWidth = ((<PostProcessOptions>this._options).width || requiredWidth);
         var desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;
 
+        const needMipMaps = 
+            this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_LINEAR &&
+            this.renderTargetSamplingMode !== Constants.TEXTURE_NEAREST_NEAREST &&
+            this.renderTargetSamplingMode !== Constants.TEXTURE_LINEAR_LINEAR;
+
+
         if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
 
             if (this.adaptScaleToCurrentViewport) {
@@ -464,7 +470,7 @@ export class PostProcess {
                 }
             }
 
-            if (this.renderTargetSamplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
+            if (needMipMaps || this.alwaysForcePOT) {
                 if (!(<PostProcessOptions>this._options).width) {
                     desiredWidth = engine.needPOTTextures ? Engine.GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
                 }
@@ -484,12 +490,6 @@ export class PostProcess {
                 this.width = desiredWidth;
                 this.height = desiredHeight;
 
-                const needMipMaps = this.renderTargetSamplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||
-                                    this.renderTargetSamplingMode === Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR ||
-                                    this.renderTargetSamplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR ||
-                                    this.renderTargetSamplingMode === Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR ||
-                                    this.renderTargetSamplingMode === Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
-
                 let textureSize = { width: this.width, height: this.height };
                 let textureOptions = {
                     generateMipMaps: needMipMaps,

BIN=BIN
tests/validation/ReferenceImages/bwpp.png


+ 5 - 0
tests/validation/config.json

@@ -2,6 +2,11 @@
     "root": "https://cdn.babylonjs.com",
     "tests": [    
         {
+            "title": "Black and White post-process",
+            "playgroundId": "#N55Q2M#0",
+            "referenceImage": "bwpp.png"
+        },       
+        {
             "title": "Node material #1",
             "playgroundId": "#QJ71C6#0",
             "referenceImage": "node-material1.png",