浏览代码

Added another Photoshop tyle blend mode: Exclusion
Performs a sort of color XOR with source and destination.
Very useful for UI highlighting but is a bizarre (and
potentially useful) effect in 3D.

pspeed42 11 年之前
父节点
当前提交
5a482e2b98

+ 3 - 0
jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java

@@ -559,6 +559,9 @@ public class OGLESShaderRenderer implements Renderer {
                     case Screen:
                         GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_COLOR);
                         break; 
+                    case Exclusion:
+                        GLES20.glBlendFunc(GLES20.GL_ONE_MINUS_DST_COLOR, GLES20.GL_ONE_MINUS_SRC_COLOR);
+                        break;
                     default:
                         throw new UnsupportedOperationException("Unrecognized blend mode: "
                                 + state.getBlendMode());

+ 9 - 1
jme3-core/src/main/java/com/jme3/material/RenderState.java

@@ -183,7 +183,15 @@ public class RenderState implements Cloneable, Savable {
          * <p>
          * Result = 1 - (1 - Source Color) * (1 - Dest Color) -> (GL_ONE, GL_ONE_MINUS_SRC_COLOR)
          */
-        Screen
+        Screen,
+        /**
+         * Mixes the destination and source colors similar to a color-based XOR
+         * operation.  This is directly equivalent to Photoshop's "Exclusion" blend.
+         * <p>
+         * Result = (Source Color * (1 - Dest Color)) + (Dest Color * (1 - Source Color))
+         *  -> (GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR) 
+         */
+        Exclusion
     }
 
     /**

+ 3 - 0
jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java

@@ -701,6 +701,9 @@ public class JoglRenderer implements Renderer {
                     case Screen:
                         gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_COLOR);
                         break; 
+                    case Exclusion:
+                        gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR);
+                        break;
                     default:
                         throw new UnsupportedOperationException("Unrecognized blend mode: "
                                 + state.getBlendMode());

+ 3 - 0
jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java

@@ -650,6 +650,9 @@ public class LwjglRenderer implements Renderer {
                     case Screen:
                         glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
                         break;       
+                    case Exclusion:
+                        glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
+                        break;
                     default:
                         throw new UnsupportedOperationException("Unrecognized blend mode: "
                                 + state.getBlendMode());