Selaa lähdekoodia

Added add mode for particle

David Catuhe 7 vuotta sitten
vanhempi
commit
f187f0be19

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1344 - 1340
dist/preview release/babylon.d.ts


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 7 - 7
dist/preview release/babylon.js


+ 24 - 10
dist/preview release/babylon.max.js

@@ -55963,11 +55963,16 @@ var BABYLON;
             }
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case ParticleSystem.BLENDMODE_ADD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 engine.setDepthWrite(true);
@@ -56259,6 +56264,10 @@ var BABYLON;
          * Blend current color and particle color using particle’s alpha.
          */
         ParticleSystem.BLENDMODE_STANDARD = 1;
+        /**
+         * Add current color and particle color multiplied by particle’s alpha.
+         */
+        ParticleSystem.BLENDMODE_ADD = 2;
         return ParticleSystem;
     }());
     BABYLON.ParticleSystem = ParticleSystem;
@@ -57311,11 +57320,16 @@ var BABYLON;
                 this._renderEffect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
             }
             // Draw order
-            if (this.blendMode === BABYLON.ParticleSystem.BLENDMODE_ONEONE) {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case BABYLON.ParticleSystem.BLENDMODE_ADD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_ONEONE:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_STANDARD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 this._engine.setDepthWrite(true);

+ 24 - 10
dist/preview release/babylon.no-module.max.js

@@ -55930,11 +55930,16 @@ var BABYLON;
             }
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case ParticleSystem.BLENDMODE_ADD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 engine.setDepthWrite(true);
@@ -56226,6 +56231,10 @@ var BABYLON;
          * Blend current color and particle color using particle’s alpha.
          */
         ParticleSystem.BLENDMODE_STANDARD = 1;
+        /**
+         * Add current color and particle color multiplied by particle’s alpha.
+         */
+        ParticleSystem.BLENDMODE_ADD = 2;
         return ParticleSystem;
     }());
     BABYLON.ParticleSystem = ParticleSystem;
@@ -57278,11 +57287,16 @@ var BABYLON;
                 this._renderEffect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
             }
             // Draw order
-            if (this.blendMode === BABYLON.ParticleSystem.BLENDMODE_ONEONE) {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case BABYLON.ParticleSystem.BLENDMODE_ADD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_ONEONE:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_STANDARD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 this._engine.setDepthWrite(true);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 14 - 14
dist/preview release/babylon.worker.js


+ 24 - 10
dist/preview release/es6.js

@@ -55930,11 +55930,16 @@ var BABYLON;
             }
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case ParticleSystem.BLENDMODE_ADD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 engine.setDepthWrite(true);
@@ -56226,6 +56231,10 @@ var BABYLON;
          * Blend current color and particle color using particle’s alpha.
          */
         ParticleSystem.BLENDMODE_STANDARD = 1;
+        /**
+         * Add current color and particle color multiplied by particle’s alpha.
+         */
+        ParticleSystem.BLENDMODE_ADD = 2;
         return ParticleSystem;
     }());
     BABYLON.ParticleSystem = ParticleSystem;
@@ -57278,11 +57287,16 @@ var BABYLON;
                 this._renderEffect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
             }
             // Draw order
-            if (this.blendMode === BABYLON.ParticleSystem.BLENDMODE_ONEONE) {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case BABYLON.ParticleSystem.BLENDMODE_ADD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_ONEONE:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_STANDARD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 this._engine.setDepthWrite(true);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 7 - 7
dist/preview release/viewer/babylon.viewer.js


+ 24 - 10
dist/preview release/viewer/babylon.viewer.max.js

@@ -56051,11 +56051,16 @@ var BABYLON;
             }
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case ParticleSystem.BLENDMODE_ADD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 engine.setDepthWrite(true);
@@ -56347,6 +56352,10 @@ var BABYLON;
          * Blend current color and particle color using particle’s alpha.
          */
         ParticleSystem.BLENDMODE_STANDARD = 1;
+        /**
+         * Add current color and particle color multiplied by particle’s alpha.
+         */
+        ParticleSystem.BLENDMODE_ADD = 2;
         return ParticleSystem;
     }());
     BABYLON.ParticleSystem = ParticleSystem;
@@ -57399,11 +57408,16 @@ var BABYLON;
                 this._renderEffect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
             }
             // Draw order
-            if (this.blendMode === BABYLON.ParticleSystem.BLENDMODE_ONEONE) {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
-            }
-            else {
-                this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            switch (this.blendMode) {
+                case BABYLON.ParticleSystem.BLENDMODE_ADD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_ONEONE:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_ONEONE);
+                    break;
+                case BABYLON.ParticleSystem.BLENDMODE_STANDARD:
+                    this._engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    break;
             }
             if (this.forceDepthWrite) {
                 this._engine.setDepthWrite(true);

+ 1 - 1
dist/preview release/what's new.md

@@ -14,7 +14,7 @@
   - Added support for `isBillboardBased`. [Doc](http://doc.babylonjs.com/babylon101/particles#alignment)
   - Added support for `minScaleX`, `minScaleY`, `maxScaleX`, `maxScaleY`. [Doc](http://doc.babylonjs.com/babylon101/particles#size)
   - Added support for `radiusRange` for sphere emitter. [Doc](http://doc.babylonjs.com/babylon101/particles#sphere-emitter)
-  
+  - Added support for `ParticleSystem.BLENDMODE_ADD` alpha mode. [Doc](http://doc.babylonjs.com/babylon101/particles#particle-colors)
 
 ## Updates
 

+ 12 - 5
src/Particles/babylon.gpuParticleSystem.ts

@@ -662,11 +662,18 @@
             }            
 
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                this._engine.setAlphaMode(Engine.ALPHA_ONEONE);
-            } else {
-                this._engine.setAlphaMode(Engine.ALPHA_COMBINE);
-            }            
+            switch(this.blendMode)
+            {
+                case ParticleSystem.BLENDMODE_ADD:
+                    this._engine.setAlphaMode(Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    this._engine.setAlphaMode(Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    this._engine.setAlphaMode(Engine.ALPHA_COMBINE);
+                    break;
+            }      
 
             if (this.forceDepthWrite) {
                 this._engine.setDepthWrite(true);

+ 16 - 4
src/Particles/babylon.particleSystem.ts

@@ -23,6 +23,11 @@
         public static BLENDMODE_STANDARD = 1;
 
         /**
+         * Add current color and particle color multiplied by particle’s alpha.
+         */
+        public static BLENDMODE_ADD = 2;
+
+        /**
          * List of animations used by the particle system.
          */
         public animations: Animation[] = [];
@@ -1057,10 +1062,17 @@
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
 
             // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(Engine.ALPHA_ONEONE);
-            } else {
-                engine.setAlphaMode(Engine.ALPHA_COMBINE);
+            switch(this.blendMode)
+            {
+                case ParticleSystem.BLENDMODE_ADD:
+                    engine.setAlphaMode(Engine.ALPHA_ADD);
+                    break;
+                case ParticleSystem.BLENDMODE_ONEONE:
+                    engine.setAlphaMode(Engine.ALPHA_ONEONE);
+                    break;
+                case ParticleSystem.BLENDMODE_STANDARD:
+                    engine.setAlphaMode(Engine.ALPHA_COMBINE);
+                    break;
             }
 
             if (this.forceDepthWrite) {

BIN
tests/validation/ReferenceImages/particles.png


BIN
tests/validation/ReferenceImages/yeti.png