From ccb946e65d8cdd725cd4e34250c672e7b2bc4e5a Mon Sep 17 00:00:00 2001 From: Hannes Nevalainen Date: Thu, 17 Apr 2014 23:06:37 +0200 Subject: [PATCH 1/4] Add Screen blend mode. --- .../src/main/java/com/jme3/material/RenderState.java | 9 ++++++++- .../main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/material/RenderState.java b/jme3-core/src/main/java/com/jme3/material/RenderState.java index ef39ddc46..0bca7ebad 100644 --- a/jme3-core/src/main/java/com/jme3/material/RenderState.java +++ b/jme3-core/src/main/java/com/jme3/material/RenderState.java @@ -176,7 +176,14 @@ public class RenderState implements Cloneable, Savable { *

* Result = 2 * Source Color * Dest Color -> (GL_DST_COLOR, GL_SRC_COLOR) */ - ModulateX2 + ModulateX2, + /** + * Opposite effect of Modulate/Multiply. Invert both colors, multiply and + * then invert the result. + *

+ * Result = 2 * Source Color * Dest Color -> (GL_ONE, GL_ONE_MINUS_SRC_COLOR) + */ + Screen } /** diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java index 408146655..3b2d44ba5 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java @@ -647,6 +647,9 @@ public class LwjglRenderer implements Renderer { case ModulateX2: glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); break; + case Screen: + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); + break; default: throw new UnsupportedOperationException("Unrecognized blend mode: " + state.getBlendMode()); From 9027b748eb5a0fc964a504273aa94f8bd6dd61f2 Mon Sep 17 00:00:00 2001 From: Hannes Nevalainen Date: Tue, 1 Jul 2014 19:19:53 +0200 Subject: [PATCH 2/4] Update javadoc for screen blend mode. --- jme3-core/src/main/java/com/jme3/material/RenderState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/material/RenderState.java b/jme3-core/src/main/java/com/jme3/material/RenderState.java index 0bca7ebad..293f39621 100644 --- a/jme3-core/src/main/java/com/jme3/material/RenderState.java +++ b/jme3-core/src/main/java/com/jme3/material/RenderState.java @@ -181,7 +181,7 @@ public class RenderState implements Cloneable, Savable { * Opposite effect of Modulate/Multiply. Invert both colors, multiply and * then invert the result. *

- * Result = 2 * Source Color * Dest Color -> (GL_ONE, GL_ONE_MINUS_SRC_COLOR) + * Result = 1 - (1 - Source Color) * (1 - Dest Color) -> (GL_ONE, GL_ONE_MINUS_SRC_COLOR) */ Screen } From 09b4ef6d82fc5930f0592de619a4403d7edf5182 Mon Sep 17 00:00:00 2001 From: Hannes Nevalainen Date: Tue, 1 Jul 2014 19:22:13 +0200 Subject: [PATCH 3/4] Screen blend mode for JOGL. --- .../src/main/java/com/jme3/renderer/jogl/JoglRenderer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java index 95e2da55b..0694bb872 100644 --- a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java +++ b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java @@ -684,6 +684,9 @@ public class JoglRenderer implements Renderer { case ModulateX2: gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_SRC_COLOR); break; + case Screen: + gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_COLOR); + break; default: throw new UnsupportedOperationException("Unrecognized blend mode: " + state.getBlendMode()); From dd88363900aedbb05f2076f15d297ef79be4180f Mon Sep 17 00:00:00 2001 From: Hannes Nevalainen Date: Tue, 1 Jul 2014 19:23:28 +0200 Subject: [PATCH 4/4] Screen blend mode for andriod. --- .../java/com/jme3/renderer/android/OGLESShaderRenderer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java b/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java index d7a6eb017..d95644189 100644 --- a/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java +++ b/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java @@ -556,6 +556,9 @@ public class OGLESShaderRenderer implements Renderer { case ModulateX2: GLES20.glBlendFunc(GLES20.GL_DST_COLOR, GLES20.GL_SRC_COLOR); break; + case Screen: + GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_COLOR); + break; default: throw new UnsupportedOperationException("Unrecognized blend mode: " + state.getBlendMode());