Sfoglia il codice sorgente

Merge pull request #619 from jahow/patch-1

Added new alpha blending modes & changed ALPHA_ADD
Temechon 10 anni fa
parent
commit
51a7f540f2
1 ha cambiato i file con 32 aggiunte e 2 eliminazioni
  1. 32 2
      src/babylon.engine.ts

+ 32 - 2
src/babylon.engine.ts

@@ -389,7 +389,10 @@
         private static _ALPHA_DISABLE = 0;
         private static _ALPHA_ADD = 1;
         private static _ALPHA_COMBINE = 2;
-
+        private static _ALPHA_SUBTRACT = 3;
+        private static _ALPHA_MULTIPLY = 4;
+        private static _ALPHA_MAXIMIZED = 5;
+        
         private static _DELAYLOADSTATE_NONE = 0;
         private static _DELAYLOADSTATE_LOADED = 1;
         private static _DELAYLOADSTATE_LOADING = 2;
@@ -416,6 +419,18 @@
             return Engine._ALPHA_COMBINE;
         }
 
+        public static get ALPHA_SUBTRACT(): number {
+            return Engine._ALPHA_SUBTRACT;
+        }
+
+        public static get ALPHA_MULTIPLY(): number {
+            return Engine._ALPHA_MULTIPLY;
+        }
+
+        public static get ALPHA_MAXIMIZED(): number {
+            return Engine._ALPHA_MAXIMIZED;
+        }
+
         public static get DELAYLOADSTATE_NONE(): number {
             return Engine._DELAYLOADSTATE_NONE;
         }
@@ -1441,7 +1456,22 @@
                     break;
                 case Engine.ALPHA_ADD:
                     this.setDepthWrite(false);
-                    this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
+                    this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
+                    this._alphaState.alphaBlend = true;
+                    break;
+                case Engine.ALPHA_SUBTRACT:
+                    this.setDepthWrite(false);
+                    this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
+                    this._alphaState.alphaBlend = true;
+                    break;
+                case Engine.ALPHA_MULTIPLY:
+                    this.setDepthWrite(false);
+                    this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
+                    this._alphaState.alphaBlend = true;
+                    break;
+                case Engine.ALPHA_MAXIMIZED:
+                    this.setDepthWrite(false);
+                    this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
                     this._alphaState.alphaBlend = true;
                     break;
             }