diff --git a/jme3-core/src/main/java/com/jme3/math/Triangle.java b/jme3-core/src/main/java/com/jme3/math/Triangle.java
index 4b98e77aa..527d6e7b4 100644
--- a/jme3-core/src/main/java/com/jme3/math/Triangle.java
+++ b/jme3-core/src/main/java/com/jme3/math/Triangle.java
@@ -44,7 +44,7 @@ import java.io.IOException;
* @author Mark Powell
* @author Joshua Slack
*/
-public class Triangle extends AbstractTriangle implements Savable, java.io.Serializable {
+public class Triangle extends AbstractTriangle implements Savable, Cloneable, java.io.Serializable {
static final long serialVersionUID = 1;
diff --git a/jme3-core/src/main/java/com/jme3/renderer/Camera.java b/jme3-core/src/main/java/com/jme3/renderer/Camera.java
index 2d4a61a45..a51ae0687 100644
--- a/jme3-core/src/main/java/com/jme3/renderer/Camera.java
+++ b/jme3-core/src/main/java/com/jme3/renderer/Camera.java
@@ -991,7 +991,7 @@ public class Camera implements Savable, Cloneable {
* Returns the pseudo distance from the given position to the near
* plane of the camera. This is used for render queue sorting.
* @param pos The position to compute a distance to.
- * @return Distance from the far plane to the point.
+ * @return Distance from the near plane to the point.
*/
public float distanceToNearPlane(Vector3f pos) {
return worldPlane[NEAR_PLANE].pseudoDistance(pos);
diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
index 1a8270435..2052f91d2 100644
--- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
+++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
@@ -1648,15 +1648,13 @@ public final class GLRenderer implements Renderer {
if (fb.getNumColorBuffers() == 0) {
// make sure to select NONE as draw buf
// no color buffer attached.
- if (gl2 != null) {
- if (context.boundDrawBuf != NONE) {
- gl2.glDrawBuffer(GL.GL_NONE);
- context.boundDrawBuf = NONE;
- }
- if (context.boundReadBuf != NONE) {
- gl2.glReadBuffer(GL.GL_NONE);
- context.boundReadBuf = NONE;
- }
+ if (context.boundDrawBuf != NONE) {
+ gl2.glDrawBuffer(GL.GL_NONE);
+ context.boundDrawBuf = NONE;
+ }
+ if (context.boundReadBuf != NONE) {
+ gl2.glReadBuffer(GL.GL_NONE);
+ context.boundReadBuf = NONE;
}
} else {
if (fb.getNumColorBuffers() > limits.get(Limits.FrameBufferAttachments)) {
@@ -1675,24 +1673,21 @@ public final class GLRenderer implements Renderer {
+ " by the video hardware!");
}
- if (context.boundDrawBuf != MRT_OFF + fb.getNumColorBuffers()) {
- intBuf16.clear();
- for (int i = 0; i < fb.getNumColorBuffers(); i++) {
- intBuf16.put(GLFbo.GL_COLOR_ATTACHMENT0_EXT + i);
- }
-
- intBuf16.flip();
- glext.glDrawBuffers(intBuf16);
- context.boundDrawBuf = MRT_OFF + fb.getNumColorBuffers();
+ intBuf16.clear();
+ for (int i = 0; i < fb.getNumColorBuffers(); i++) {
+ intBuf16.put(GLFbo.GL_COLOR_ATTACHMENT0_EXT + i);
}
+
+ intBuf16.flip();
+ glext.glDrawBuffers(intBuf16);
+ context.boundDrawBuf = MRT_OFF + fb.getNumColorBuffers();
+
} else {
RenderBuffer rb = fb.getColorBuffer(fb.getTargetIndex());
// select this draw buffer
- if (gl2 != null) {
- if (context.boundDrawBuf != rb.getSlot()) {
- gl2.glDrawBuffer(GLFbo.GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
- context.boundDrawBuf = rb.getSlot();
- }
+ if (context.boundDrawBuf != rb.getSlot()) {
+ gl2.glDrawBuffer(GLFbo.GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
+ context.boundDrawBuf = rb.getSlot();
}
}
}
diff --git a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java
index a3f825d26..e5755c595 100644
--- a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java
+++ b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java
@@ -363,6 +363,30 @@ public class FrameBuffer extends NativeObject {
colorBufs.clear();
}
+ /**
+ * Add a color buffer without a texture bound to it.
+ * If MRT is enabled, then each subsequently added texture or buffer can be
+ * rendered to through a shader that writes to the array gl_FragData
.
+ * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) }
+ * is rendered to by the shader.
+ *
+ * @param format the format of the color buffer
+ * @see #addColorTexture(com.jme3.texture.Texture2D)
+ */
+ public void addColorBuffer(Image.Format format){
+ if (id != -1)
+ throw new UnsupportedOperationException("FrameBuffer already initialized.");
+
+ if (format.isDepthFormat())
+ throw new IllegalArgumentException("Color buffer format must be color/luminance.");
+
+ RenderBuffer colorBuf = new RenderBuffer();
+ colorBuf.slot = colorBufs.size();
+ colorBuf.format = format;
+
+ colorBufs.add(colorBuf);
+ }
+
/**
* Add a color texture to use for this framebuffer.
* If MRT is enabled, then each subsequently added texture can be
@@ -371,6 +395,7 @@ public class FrameBuffer extends NativeObject {
* is rendered to by the shader.
*
* @param tex The texture to add.
+ * @see #addColorBuffer(com.jme3.texture.Image.Format)
*/
public void addColorTexture(Texture2D tex) {
if (id != -1)
diff --git a/jme3-core/src/main/java/com/jme3/util/clone/JmeCloneable.java b/jme3-core/src/main/java/com/jme3/util/clone/JmeCloneable.java
index 6b278b222..13a9e0e71 100644
--- a/jme3-core/src/main/java/com/jme3/util/clone/JmeCloneable.java
+++ b/jme3-core/src/main/java/com/jme3/util/clone/JmeCloneable.java
@@ -49,7 +49,7 @@ package com.jme3.util.clone;
*
*
Cloning of a JmeCloneable object is done in two parts. First, * the standard Java clone() method is called to create a shallow clone - * of the object. Second, the cloner wil lcall the cloneFields() method + * of the object. Second, the cloner will call the cloneFields() method * to let the object deep clone any of its fields that should be cloned.
* *This two part process is necessary to facilitate circular references.
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
index 27ea29aa4..0bd396383 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
@@ -9,7 +9,9 @@ varying vec2 texCoord;
varying vec2 texCoord2;
#endif
-varying vec4 Color;
+#ifndef BASECOLORMAP
+ varying vec4 Color;
+#endif
uniform vec4 g_LightData[NB_LIGHTS];
@@ -122,7 +124,7 @@ void main(){
float Metallic = max(m_Metallic, 0.0);
#endif
- float alpha = Color.a * albedo.a;
+ float alpha = albedo.a;
#ifdef DISCARD_ALPHA
if(alpha < m_AlphaDiscardThreshold){
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
index 586e8f5e7..864ff9877 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
@@ -154,7 +154,6 @@ MaterialDef PBR Lighting {
}
Defines {
- COLOR_MAP : ColorMap
DISCARD_ALPHA : AlphaDiscardThreshold
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
@@ -187,7 +186,7 @@ MaterialDef PBR Lighting {
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
- COLOR_MAP : ColorMap
+ SHADOWMAP_SIZE : ShadowMapSize
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
@@ -219,7 +218,6 @@ MaterialDef PBR Lighting {
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
- COLOR_MAP : ColorMap
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
@@ -249,29 +247,6 @@ MaterialDef PBR Lighting {
}
Defines {
- DIFFUSEMAP_ALPHA : DiffuseMap
- NUM_BONES : NumberOfBones
- INSTANCING : UseInstancing
- }
-
- }
-
-
- Technique PreNormalPassDerivative {
-
- VertexShader GLSL100 : Common/MatDefs/MSSAO/normal.vert
- FragmentShader GLSL100 : Common/MatDefs/MSSAO/normal.frag
-
- WorldParameters {
- WorldViewProjectionMatrix
- WorldViewMatrix
- NormalMatrix
- ViewProjectionMatrix
- ViewMatrix
- }
-
- Defines {
- DIFFUSEMAP_ALPHA : DiffuseMap
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
}
@@ -292,12 +267,6 @@ MaterialDef PBR Lighting {
Defines {
VERTEX_COLOR : UseVertexColor
- MATERIAL_COLORS : UseMaterialColors
- V_TANGENT : VTangent
- MINNAERT : Minnaert
- WARDISO : WardIso
-
- DIFFUSEMAP : DiffuseMap
NORMALMAP : NormalMap
SPECULARMAP : SpecularMap
PARALLAXMAP : ParallaxMap
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.vert
index 77782456b..c5cb00075 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.vert
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.vert
@@ -13,7 +13,9 @@ varying vec2 texCoord;
attribute vec2 inTexCoord2;
#endif
-varying vec4 Color;
+#ifndef BASECOLORMAP
+ varying vec4 Color;
+#endif
attribute vec3 inPosition;
attribute vec2 inTexCoord;
@@ -59,7 +61,9 @@ void main(){
wTangent = vec4(TransformWorldNormal(modelSpaceTan),inTangent.w);
#endif
- Color = m_BaseColor;
+ #ifndef BASECOLORMAP
+ Color = m_BaseColor;
+ #endif
#ifdef VERTEX_COLOR
Color *= inColor;
diff --git a/jme3-ios/src/main/java/com/jme3/system/ios/IosHarness.java b/jme3-ios/src/main/java/com/jme3/system/ios/IosHarness.java
index f3b10196e..7a47d8ff9 100644
--- a/jme3-ios/src/main/java/com/jme3/system/ios/IosHarness.java
+++ b/jme3-ios/src/main/java/com/jme3/system/ios/IosHarness.java
@@ -31,7 +31,7 @@
*/
package com.jme3.system.ios;
-import com.jme3.app.Application;
+import com.jme3.app.LegacyApplication;
import com.jme3.system.JmeSystem;
/**
@@ -39,7 +39,7 @@ import com.jme3.system.JmeSystem;
*/
public abstract class IosHarness extends ObjcNativeObject {
- protected Application app;
+ protected LegacyApplication app;
public IosHarness(long appDelegate) {
super(appDelegate);
diff --git a/jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/LwjglMouseInput.java b/jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/LwjglMouseInput.java
index a91aab36e..f3982fd25 100644
--- a/jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/LwjglMouseInput.java
+++ b/jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/LwjglMouseInput.java
@@ -39,6 +39,8 @@ import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.system.lwjgl.LwjglAbstractDisplay;
import com.jme3.system.lwjgl.LwjglTimer;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
@@ -57,6 +59,12 @@ public class LwjglMouseInput implements MouseInput {
private boolean supportHardwareCursor = false;
private boolean cursorVisible = true;
+ /**
+ * We need to cache the cursors
+ * (https://github.com/jMonkeyEngine/jmonkeyengine/issues/537)
+ */
+ private Map