caps) {
+ supportUnpackRowLength = caps.contains(Caps.UnpackRowLength);
this.formats = GLImageFormats.getFormatsForCaps(caps);
if (logger.isLoggable(Level.FINE)) {
StringBuilder sb = new StringBuilder();
@@ -142,13 +144,13 @@ private void uploadTextureLevel(GLImageFormat format, int target, int level, int
if (target == GL2.GL_TEXTURE_3D) {
// For 3D textures, we upload the entire mipmap level.
gl2.glCompressedTexImage3D(target,
- level,
- format.internalFormat,
- width,
- height,
- depth,
- 0,
- data);
+ level,
+ format.internalFormat,
+ width,
+ height,
+ depth,
+ 0,
+ data);
} else if (target == GLExt.GL_TEXTURE_2D_ARRAY_EXT) {
// For texture arrays, only upload 1 slice at a time.
// zoffset specifies slice index, and depth is 1 to indicate
@@ -298,6 +300,10 @@ public void uploadTexture(Image image,
}
}
+ /**
+ * @deprecated Use uploadSubTexture(int target, Image src, int index,int targetX, int targetY,int srcX,int srcY, int areaWidth,int areaHeight, boolean linearizeSrgb)
+ */
+ @Deprecated
public void uploadSubTexture(Image image, int target, int index, int x, int y, boolean linearizeSrgb) {
if (target != GL.GL_TEXTURE_2D || image.getDepth() > 1) {
throw new UnsupportedOperationException("Updating non-2D texture is not supported");
@@ -338,4 +344,63 @@ public void uploadSubTexture(Image image, int target, int index, int x, int y, b
gl.glTexSubImage2D(target, 0, x, y, image.getWidth(), image.getHeight(),
oglFormat.format, oglFormat.dataType, data);
}
+
+ public void uploadSubTexture(int target, Image src, int index, int targetX, int targetY, int areaX, int areaY, int areaWidth, int areaHeight, boolean linearizeSrgb) {
+ if (target != GL.GL_TEXTURE_2D || src.getDepth() > 1) {
+ throw new UnsupportedOperationException("Updating non-2D texture is not supported");
+ }
+
+ if (src.getMipMapSizes() != null) {
+ throw new UnsupportedOperationException("Updating mip-mappped images is not supported");
+ }
+
+ if (src.getMultiSamples() > 1) {
+ throw new UnsupportedOperationException("Updating multisampled images is not supported");
+ }
+
+ Image.Format jmeFormat = src.getFormat();
+
+ if (jmeFormat.isCompressed()) {
+ throw new UnsupportedOperationException("Updating compressed images is not supported");
+ } else if (jmeFormat.isDepthFormat()) {
+ throw new UnsupportedOperationException("Updating depth images is not supported");
+ }
+
+ boolean getSrgbFormat = src.getColorSpace() == ColorSpace.sRGB && linearizeSrgb;
+ GLImageFormat oglFormat = getImageFormatWithError(jmeFormat, getSrgbFormat);
+
+ ByteBuffer data = src.getData(index);
+
+ if (data == null) {
+ throw new IndexOutOfBoundsException("The image index " + index + " is not valid for the given image");
+ }
+
+ int Bpp = src.getFormat().getBitsPerPixel() / 8;
+
+ int srcWidth = src.getWidth();
+ int cpos = data.position();
+ int skip = areaX;
+ skip += areaY * srcWidth;
+ skip *= Bpp;
+
+ data.position(skip);
+
+ boolean needsStride = srcWidth != areaWidth;
+
+ if (needsStride && (!supportUnpackRowLength)) { // doesn't support stride, copy row by row (slower).
+ for (int i = 0; i < areaHeight; i++) {
+ data.position(skip + (srcWidth * Bpp * i));
+ gl.glTexSubImage2D(target, 0, targetX, targetY + i, areaWidth, 1, oglFormat.format, oglFormat.dataType, data);
+ }
+ } else {
+ if (needsStride)
+ gl2.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, srcWidth);
+ gl.glTexSubImage2D(target, 0, targetX, targetY, areaWidth, areaHeight, oglFormat.format, oglFormat.dataType, data);
+ if (needsStride)
+ gl2.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0);
+ }
+ data.position(cpos);
+
+ }
+
}
diff --git a/jme3-core/src/main/java/com/jme3/scene/SceneGraphVisitorAdapter.java b/jme3-core/src/main/java/com/jme3/scene/SceneGraphVisitorAdapter.java
index 8fa419e750..7cde0d266b 100644
--- a/jme3-core/src/main/java/com/jme3/scene/SceneGraphVisitorAdapter.java
+++ b/jme3-core/src/main/java/com/jme3/scene/SceneGraphVisitorAdapter.java
@@ -51,9 +51,9 @@ public void visit(Geometry geom) {}
/**
* Called when a {@link Node} is visited.
*
- * @param geom The visited node
+ * @param node The visited node
*/
- public void visit(Node geom) {}
+ public void visit(Node node) {}
@Override
public final void visit(Spatial spatial) {
diff --git a/jme3-core/src/main/java/com/jme3/scene/shape/Line.java b/jme3-core/src/main/java/com/jme3/scene/shape/Line.java
index e2ac6d85c3..93e667d7c5 100644
--- a/jme3-core/src/main/java/com/jme3/scene/shape/Line.java
+++ b/jme3-core/src/main/java/com/jme3/scene/shape/Line.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,8 +51,11 @@ public class Line extends Mesh {
private Vector3f start;
private Vector3f end;
-
- public Line() {
+
+ /**
+ * No-argument constructor needed by SavableClassUtil.
+ */
+ public Line() { // TODO protected
}
public Line(Vector3f start, Vector3f end) {
@@ -79,9 +82,16 @@ protected void updateGeometry(Vector3f start, Vector3f end) {
}
/**
- * Update the start and end points of the line.
+ * Alter the start and end.
+ *
+ * @param start the desired mesh location of the start (not null,
+ * unaffected)
+ * @param end the desired mesh location of the end (not null, unaffected)
*/
public void updatePoints(Vector3f start, Vector3f end) {
+ this.start.set(start);
+ this.end.set(end);
+
VertexBuffer posBuf = getBuffer(Type.Position);
FloatBuffer fb = (FloatBuffer) posBuf.getData();
diff --git a/jme3-core/src/main/java/com/jme3/shader/Glsl300ShaderGenerator.java b/jme3-core/src/main/java/com/jme3/shader/Glsl300ShaderGenerator.java
new file mode 100644
index 0000000000..450a21a5ff
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/shader/Glsl300ShaderGenerator.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009-2012 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.shader;
+
+import com.jme3.asset.AssetManager;
+import com.jme3.material.ShaderGenerationInfo;
+import com.jme3.shader.Shader.ShaderType;
+
+
+/**
+ * This shader Generator can generate Vertex and Fragment shaders from
+ * ShaderNodes for GLESSL 3.0
+ * Nowdays it's just a subclass of Glsl150ShaderGenerator overriding the version
+ * string because GLSL 1.5 is mostly compatible with GLESSL 3.0
+ *
+ * @author Nehon
+ * @author Joliver82
+ */
+public class Glsl300ShaderGenerator extends Glsl150ShaderGenerator {
+
+ /**
+ * Creates a Glsl300ShaderGenerator
+ *
+ * @param assetManager the assetmanager
+ */
+ public Glsl300ShaderGenerator(AssetManager assetManager) {
+ super(assetManager);
+ }
+
+ @Override
+ protected String getLanguageAndVersion(ShaderType type) {
+ return "GLSL300";
+ }
+
+}
diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
index 26e79aacc1..71c4176327 100644
--- a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
+++ b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -169,8 +169,13 @@ public Platform getPlatform() {
boolean is64 = is64Bit(arch);
if (os.contains("windows")) {
return is64 ? Platform.Windows64 : Platform.Windows32;
- } else if (os.contains("linux") || os.contains("freebsd") || os.contains("sunos")) {
- return is64 ? Platform.Linux64 : Platform.Linux32;
+ } else if (os.contains("linux") || os.contains("freebsd")
+ || os.contains("sunos") || os.contains("unix")) {
+ if (arch.startsWith("arm")) {
+ return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32;
+ } else {
+ return is64 ? Platform.Linux64 : Platform.Linux32;
+ }
} else if (os.contains("mac os x") || os.contains("darwin")) {
if (arch.startsWith("ppc")) {
return is64 ? Platform.MacOSX_PPC64 : Platform.MacOSX_PPC32;
diff --git a/jme3-core/src/main/java/com/jme3/system/Platform.java b/jme3-core/src/main/java/com/jme3/system/Platform.java
index f9206d33f8..1b80ff2e25 100644
--- a/jme3-core/src/main/java/com/jme3/system/Platform.java
+++ b/jme3-core/src/main/java/com/jme3/system/Platform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,22 +44,32 @@ public enum Platform {
Windows64(true),
/**
- * Linux 32 bit
+ * Linux 32-bit Intel
*/
Linux32,
/**
- * Linux 64 bit
+ * Linux 64-bit Intel
*/
Linux64(true),
/**
- * Apple Mac OS X 32 bit
+ * Linux 32-bit ARM
+ */
+ Linux_ARM32,
+
+ /**
+ * Linux 64-bit ARM
+ */
+ Linux_ARM64(true),
+
+ /**
+ * Apple Mac OS X 32-bit Intel
*/
MacOSX32,
/**
- * Apple Mac OS X 64 bit
+ * Apple Mac OS X 64-bit Intel
*/
MacOSX64(true),
diff --git a/jme3-core/src/main/java/com/jme3/texture/Image.java b/jme3-core/src/main/java/com/jme3/texture/Image.java
index eaa3aae8a4..f7cee1b55e 100644
--- a/jme3-core/src/main/java/com/jme3/texture/Image.java
+++ b/jme3-core/src/main/java/com/jme3/texture/Image.java
@@ -494,6 +494,11 @@ public enum Format {
* Requires {@link Caps#FloatTexture}.
*/
RG32F(64,true),
+
+ /**
+ * 10-bit red, green, and blue with 2-bit alpha.
+ */
+ RGB10A2(32),
;
private int bpp;
diff --git a/jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java b/jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java
index bbad96ace8..993ce508b4 100644
--- a/jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java
+++ b/jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java
@@ -130,6 +130,10 @@ public ImageCodec(int bpp, int flags, int maxAlpha, int maxRed, int maxGreen, in
0, 11, 6, 1));
((BitMaskImageCodec)params.get(Format.RGB5A1)).be = true;
+ params.put(Format.RGB10A2, new BitMaskImageCodec(4, 0,
+ 2, 10, 10, 10,
+ 0, 22, 12, 2));
+
// params.put(Format.RGBA8, new ByteAlignedImageCodec(4, 0,
// 0, 1, 1, 1,
// 0, 0, 1, 2));
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md
index e409926963..977007f073 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md
@@ -10,8 +10,8 @@ MaterialDef Radial Blur {
}
Technique {
- VertexShader GLSL120 GLSL150: Common/MatDefs/Post/Post.vert
- FragmentShader GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag
+ VertexShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Post/Post.vert
+ FragmentShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag
WorldParameters {
}
@@ -20,4 +20,4 @@ MaterialDef Radial Blur {
RESOLVE_MS : NumSamples
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md
index 824a173696..4a5fa256ee 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md
@@ -133,8 +133,8 @@ MaterialDef Phong Lighting {
Technique {
LightMode SinglePass
- VertexShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -180,8 +180,8 @@ MaterialDef Phong Lighting {
LightMode MultiPass
- VertexShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -225,8 +225,8 @@ MaterialDef Phong Lighting {
Technique PreShadow {
- VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
- FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -255,8 +255,8 @@ MaterialDef Phong Lighting {
Technique PostShadow {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -292,8 +292,8 @@ MaterialDef Phong Lighting {
Technique PreNormalPass {
- VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
- FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -315,8 +315,8 @@ MaterialDef Phong Lighting {
Technique Glow {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
WorldParameters {
WorldViewProjectionMatrix
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 077b08579f..4eaa6a88f5 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
@@ -296,7 +296,7 @@ void main(){
weight3 /= weightSum;
#endif
- #if USE_AMBIENT_LIGHT
+ #ifdef USE_AMBIENT_LIGHT
color1.rgb *= g_AmbientLightColor.rgb;
color2.rgb *= g_AmbientLightColor.rgb;
color3.rgb *= g_AmbientLightColor.rgb;
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 8465d2f0b2..40b4f9a6c7 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
@@ -123,8 +123,8 @@ MaterialDef PBR Lighting {
Technique {
LightMode SinglePassAndImageBased
- VertexShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert
- FragmentShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag
+ VertexShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert
+ FragmentShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -167,8 +167,8 @@ MaterialDef PBR Lighting {
Technique PreShadow {
- VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
- FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
+ VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
+ FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -197,8 +197,8 @@ MaterialDef PBR Lighting {
Technique PostShadow{
- VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert
- FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters {
WorldViewProjectionMatrix
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md
index f765d20445..4c609dca8d 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md
@@ -62,8 +62,8 @@ MaterialDef Unshaded {
}
Technique {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -88,8 +88,8 @@ MaterialDef Unshaded {
Technique PreNormalPass {
- VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
- FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -109,8 +109,8 @@ MaterialDef Unshaded {
Technique PreShadow {
- VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
- FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -140,8 +140,8 @@ MaterialDef Unshaded {
Technique PostShadow {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -176,8 +176,8 @@ MaterialDef Unshaded {
Technique Glow {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -196,4 +196,4 @@ MaterialDef Unshaded {
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping.j3sn b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping.j3sn
index 148c88f1c5..529dea4bae 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping.j3sn
+++ b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping.j3sn
@@ -2,6 +2,7 @@ ShaderNodeDefinitions{
ShaderNodeDefinition EnvMapping {
Type: Fragment
+ Shader GLSL300: Common/MatDefs/ShaderNodes/Environment/envMapping130.frag
Shader GLSL100: Common/MatDefs/ShaderNodes/Environment/envMapping100.frag
Shader GLSL130: Common/MatDefs/ShaderNodes/Environment/envMapping130.frag
@@ -19,4 +20,4 @@ ShaderNodeDefinitions{
vec4 color
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping100.frag b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping100.frag
index 9d40ec523b..29932c7c5a 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping100.frag
+++ b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Environment/envMapping100.frag
@@ -1,8 +1,17 @@
#extension GL_ARB_shader_texture_lod : enable
+#extension GL_EXT_shader_texture_lod : enable
void main(){
//@input vec3 refVec the reflection vector
//@input samplerCube cubeMap the cube map
//@output vec4 color the output color
- color = textureCubeLod(cubeMap, refVec, 0.0);
-}
\ No newline at end of file
+ #ifdef GL_ES
+ #ifdef GL_EXT_shader_texture_lod
+ color = textureCubeLodEXT(cubeMap, refVec, 0.0);
+ #else
+ color = textureCube(cubeMap, refVec);
+ #endif
+ #else
+ color = textureCubeLod(cubeMap, refVec, 0.0);
+ #endif
+}
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md
index fd8ea8a24d..ce588b60af 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md
@@ -35,8 +35,8 @@ MaterialDef Post Shadow {
}
Technique {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
+ VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
+ FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -61,4 +61,4 @@ MaterialDef Post Shadow {
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md
index 0023b0b813..05188796c6 100644
--- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md
+++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md
@@ -42,8 +42,8 @@ MaterialDef Post Shadow {
}
Technique {
- VertexShader GLSL150: Common/MatDefs/Shadow/PostShadowFilter.vert
- FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadowFilter15.frag
+ VertexShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter.vert
+ FragmentShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter15.frag
WorldParameters {
ResolutionInverse
@@ -88,4 +88,4 @@ MaterialDef Post Shadow {
-}
\ No newline at end of file
+}
diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib
index c1ace91d12..697db195d5 100644
--- a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib
+++ b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib
@@ -19,13 +19,18 @@
#endif
#if __VERSION__ >= 130
+# ifdef GL_ES
+out highp vec4 outFragColor;
+# else
out vec4 outFragColor;
+#endif
# define texture1D texture
# define texture2D texture
# define texture3D texture
# define textureCube texture
# define texture2DLod textureLod
# define textureCubeLod textureLod
+# define texture2DArray texture
# if defined VERTEX_SHADER
# define varying out
# define attribute in
@@ -33,4 +38,8 @@ out vec4 outFragColor;
# define varying in
# define gl_FragColor outFragColor
# endif
-#endif
\ No newline at end of file
+#else
+# define isnan(val) !(val<0.0||val>0.0||val==0.0)
+#endif
+
+
diff --git a/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib
index 4ecd331576..8dc1e2a728 100644
--- a/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib
+++ b/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib
@@ -16,7 +16,7 @@ uniform int m_NumSamplesDepth;
#endif
// NOTE: Only define multisample functions if multisample is available
-#if defined(GL_ARB_texture_multisample)
+#if defined(GL_ARB_texture_multisample) || (defined GL_ES && __VERSION__>=310)
vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){
ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
vec4 color = vec4(0.0);
diff --git a/jme3-core/src/main/resources/Common/ShaderLib/Shadows.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/Shadows.glsllib
index c7c6b88518..eb3380ce1f 100644
--- a/jme3-core/src/main/resources/Common/ShaderLib/Shadows.glsllib
+++ b/jme3-core/src/main/resources/Common/ShaderLib/Shadows.glsllib
@@ -1,16 +1,23 @@
#if __VERSION__ >= 130
// Because gpu_shader5 is actually where those
// gather functions are declared to work on shadowmaps
- #extension GL_ARB_gpu_shader5 : enable
+ // This "if" statement is useless as jme3 changes line ordering, so all extensions are tried to be loaded
+ #ifdef GL_ES
+ #extension GL_OES_gpu_shader5 : enable
+ #else
+ #extension GL_ARB_gpu_shader5 : enable
+ #endif
+
#define IVEC2 ivec2
- #if defined GL_ES
- #define SHADOWMAP sampler2D
- #define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
- #elif defined HARDWARE_SHADOWS
+ #ifdef HARDWARE_SHADOWS
#define SHADOWMAP sampler2DShadow
#define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)
#define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)
- #define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)
+ #if defined GL_ES && __VERSION__ <= 300
+ #define SHADOWGATHER(tex,coord) step(coord.z, textureGather(tex, coord.xy))
+ #else
+ #define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)
+ #endif
#else
#define SHADOWMAP sampler2D
#define SHADOWCOMPAREOFFSET(tex,coord,offset) step(coord.z, textureProjOffset(tex, coord, offset).r)
@@ -31,7 +38,10 @@
#endif
#else
#define IVEC2 vec2
- #ifdef HARDWARE_SHADOWS
+ #if defined GL_ES
+ #define SHADOWMAP sampler2D
+ #define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
+ #elif defined HARDWARE_SHADOWS
#define SHADOWMAP sampler2DShadow
#define SHADOWCOMPARE(tex,coord) shadow2DProj(tex, coord).r
#else
@@ -91,10 +101,14 @@ float Shadow_DoShadowCompare(in SHADOWMAP tex,in vec4 projCoord){
}
float Shadow_BorderCheck(in vec2 coord){
- // Fastest, "hack" method (uses 4-5 instructions)
- vec4 t = vec4(coord.xy, 0.0, 1.0);
- t = step(t.wwxy, t.xyzz);
- return dot(t,t);
+ #ifdef GL_ES
+ return 0.0;
+ #else
+ // Fastest, "hack" method (uses 4-5 instructions)
+ vec4 t = vec4(coord.xy, 0.0, 1.0);
+ t = step(t.wwxy, t.xyzz);
+ return dot(t,t);
+ #endif
}
float Shadow_Nearest(in SHADOWMAP tex,in vec4 projCoord){
@@ -117,7 +131,8 @@ float Shadow_DoDither_2x2(in SHADOWMAP tex, in vec4 projCoord){
return 1.0;
float shadow = 0.0;
- IVEC2 o = IVEC2(mod(floor(gl_FragCoord.xy), 2.0));
+ //IVEC2 o = IVEC2(mod(floor(gl_FragCoord.xy), 2.0));
+ vec2 o = vec2(IVEC2(mod(floor(gl_FragCoord.xy), 2.0))); //Strict type checking in GLSL ES
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2(-1.5, 1.5)+o));
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2( 0.5, 1.5)+o));
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2(-1.5, -0.5)+o));
@@ -134,7 +149,7 @@ float Shadow_DoBilinear_2x2(in SHADOWMAP tex, in vec4 projCoord){
vec4 gather = vec4(0.0);
#if __VERSION__ >= 130
- #ifdef GL_ARB_gpu_shader5
+ #if defined GL_ARB_gpu_shader5 || defined GL_OES_gpu_shader5
vec4 coord = vec4(projCoord.xyz / projCoord.www,0.0);
gather = SHADOWGATHER(tex, coord);
#else
diff --git a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
index d4c24054dc..93f082337b 100644
--- a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
+++ b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
@@ -345,16 +345,7 @@ public Savable readObject(int id) {
return out;
- } catch (IOException e) {
- logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)", "Exception", e);
- return null;
- } catch (ClassNotFoundException e) {
- logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)", "Exception", e);
- return null;
- } catch (InstantiationException e) {
- logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)", "Exception", e);
- return null;
- } catch (IllegalAccessException e) {
+ } catch (Exception e) {
logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int id)", "Exception", e);
return null;
}
diff --git a/jme3-core/src/plugins/java/com/jme3/shader/plugins/GLSLLoader.java b/jme3-core/src/plugins/java/com/jme3/shader/plugins/GLSLLoader.java
index ce3264b2d5..3c4dd91300 100644
--- a/jme3-core/src/plugins/java/com/jme3/shader/plugins/GLSLLoader.java
+++ b/jme3-core/src/plugins/java/com/jme3/shader/plugins/GLSLLoader.java
@@ -191,7 +191,7 @@ public Object load(AssetInfo info) throws IOException {
if (info.getKey() instanceof ShaderAssetKey) {
injectDependencies = ((ShaderAssetKey) info.getKey()).isInjectDependencies();
}
- if (info.getKey().getExtension().equals("glsllib")) {
+ if (info.getKey().getExtension().equals("glsllib")||info.getKey().getExtension().equals("glsl")) {
// NOTE: Loopback, GLSLLIB is loaded by this loader
// and needs data as InputStream
return reader;
diff --git a/jme3-core/src/test/groovy/com/jme3/app/state/AppStateManagerTest.groovy b/jme3-core/src/test/groovy/com/jme3/app/state/AppStateManagerTest.groovy
new file mode 100644
index 0000000000..45e39c1b79
--- /dev/null
+++ b/jme3-core/src/test/groovy/com/jme3/app/state/AppStateManagerTest.groovy
@@ -0,0 +1,98 @@
+package com.jme3.app.state;
+
+import com.jme3.app.LegacyApplication;
+
+class AppStateManagerTest {
+
+ static class AttachTest extends GroovyTestCase {
+
+ void testDuplicateId() {
+ def state1 = new AbstractAppState("test1") {};
+ def state2 = new AbstractAppState("test1") {};
+
+ def app = new LegacyApplication();
+
+ app.getStateManager().attach(state1);
+
+ shouldFail(IllegalArgumentException) {
+ app.getStateManager().attach(state2);
+ }
+ }
+
+ void testDuplicateNullId() {
+ // Make sure that two states without an ID can
+ // still be registered.
+ def state1 = new AbstractAppState() {};
+ def state2 = new AbstractAppState() {};
+
+ def app = new LegacyApplication();
+
+ app.getStateManager().attach(state1);
+ app.getStateManager().attach(state2);
+ }
+ }
+
+ static class GetStateWithIdTest extends GroovyTestCase {
+ void testIdHit() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+
+ assertNotNull app.stateManager.getState("test1", AppState.class);
+ }
+
+ void testIdMiss() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+
+ assertNull app.stateManager.getState("test2", AppState.class);
+ }
+
+ void testDetached() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+ app.stateManager.detach(state);
+
+ assertNull app.stateManager.getState("test2", AppState.class);
+ }
+ }
+
+ static class StateForIdTest extends GroovyTestCase {
+ void testIdHit() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+
+ assertNotNull app.stateManager.stateForId("test1", AppState.class);
+ }
+
+ void testIdMiss() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+
+ shouldFail(IllegalArgumentException) {
+ app.stateManager.stateForId("test2", AppState.class);
+ }
+ }
+
+ void testDetached() {
+ def state = new AbstractAppState("test1") {};
+ def app = new LegacyApplication();
+
+ app.stateManager.attach(state);
+ app.stateManager.detach(state);
+
+ shouldFail(IllegalArgumentException) {
+ app.stateManager.stateForId("test2", AppState.class);
+ }
+ }
+ }
+}
diff --git a/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java b/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java
index 0007bca2c6..e4f3e57a8b 100644
--- a/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java
+++ b/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java
@@ -46,6 +46,7 @@ public void testLoadShaderSource() {
assetManager.registerLocator(null, ClasspathLocator.class);
assetManager.registerLoader(GLSLLoader.class, "frag");
assetManager.registerLoader(GLSLLoader.class, "glsllib");
+ assetManager.registerLoader(GLSLLoader.class, "glsl");
String showNormals = (String) assetManager.loadAsset("Common/MatDefs/Misc/ShowNormals.frag");
System.out.println(showNormals);
}
diff --git a/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java b/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
index 98d379b38a..ad4bf1dd18 100644
--- a/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
+++ b/jme3-core/src/tools/java/jme3tools/shadercheck/ShaderCheck.java
@@ -31,7 +31,7 @@ private static void initAssetManager(){
assetManager.registerLocator("/", ClasspathLocator.class);
assetManager.registerLoader(J3MLoader.class, "j3m");
assetManager.registerLoader(J3MLoader.class, "j3md");
- assetManager.registerLoader(GLSLLoader.class, "vert", "frag","geom","tsctrl","tseval","glsllib");
+ assetManager.registerLoader(GLSLLoader.class, "vert", "frag","geom","tsctrl","tseval","glsllib","glsl");
}
private static void checkMatDef(String matdefName) {
diff --git a/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java b/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
index c5faa0a74e..1cba8bcf28 100644
--- a/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
+++ b/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -175,6 +175,8 @@ public static void registerNativeLibrary(String name, Platform platform,
registerNativeLibrary("bulletjme", Platform.Windows64, "native/windows/x86_64/bulletjme.dll");
registerNativeLibrary("bulletjme", Platform.Linux32, "native/linux/x86/libbulletjme.so");
registerNativeLibrary("bulletjme", Platform.Linux64, "native/linux/x86_64/libbulletjme.so");
+ registerNativeLibrary("bulletjme", Platform.Linux_ARM32, "native/linux/arm32/libbulletjme.so");
+ registerNativeLibrary("bulletjme", Platform.Linux_ARM64, "native/linux/arm64/libbulletjme.so");
registerNativeLibrary("bulletjme", Platform.MacOSX32, "native/osx/x86/libbulletjme.dylib");
registerNativeLibrary("bulletjme", Platform.MacOSX64, "native/osx/x86_64/libbulletjme.dylib");
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md
index 68f329892b..2debc760c7 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md
+++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md
@@ -8,10 +8,10 @@ MaterialDef FXAA {
Float ReduceMul
}
Technique {
- VertexShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert
- FragmentShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag
+ VertexShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert
+ FragmentShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag
WorldParameters {
ResolutionInverse
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md
index 613955536b..590dbdc051 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md
+++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md
@@ -14,8 +14,8 @@ MaterialDef Light Scattering {
}
Technique {
- VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
- FragmentShader GLSL150 GLSL120: Common/MatDefs/Post/LightScattering.frag
+ VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
+ FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/LightScattering.frag
WorldParameters {
}
@@ -26,4 +26,4 @@ MaterialDef Light Scattering {
DISPLAY: Display
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md
index 6cf780e1f1..0f5b5433e7 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md
+++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md
@@ -18,8 +18,8 @@ MaterialDef SSAO {
}
Technique {
- VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
- FragmentShader GLSL150 GLSL120: Common/MatDefs/SSAO/ssao.frag
+ VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
+ FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/SSAO/ssao.frag
WorldParameters {
WorldViewMatrix
@@ -34,4 +34,4 @@ MaterialDef SSAO {
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.frag b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.frag
index ef6b278ec5..aaa7bd8acb 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.frag
+++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.frag
@@ -32,77 +32,77 @@ vec4 convolutionFilter(){
float zsum = 1.0;
float Zp =readDepth(texCoord);
- vec2 sample = vec2(x - 2.0 * xScale, y - 2.0 * yScale);
- float zTmp = readDepth(sample);
+ vec2 samplePos = vec2(x - 2.0 * xScale, y - 2.0 * yScale);
+ float zTmp = readDepth(samplePos);
float coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 0.0 * xScale, y - 2.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 0.0 * xScale, y - 2.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x + 2.0 * xScale, y - 2.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x + 2.0 * xScale, y - 2.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 1.0 * xScale, y - 1.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 1.0 * xScale, y - 1.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x + 1.0 * xScale, y - 1.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x + 1.0 * xScale, y - 1.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 2.0 * xScale, y - 0.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 2.0 * xScale, y - 0.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x + 2.0 * xScale, y - 0.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x + 2.0 * xScale, y - 0.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 1.0 * xScale, y + 1.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 1.0 * xScale, y + 1.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x + 1.0 * xScale, y + 1.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x + 1.0 * xScale, y + 1.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 2.0 * xScale, y + 2.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 2.0 * xScale, y + 2.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x - 0.0 * xScale, y + 2.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x - 0.0 * xScale, y + 2.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
- sample = vec2(x + 2.0 * xScale, y + 2.0 * yScale);
- zTmp =readDepth(sample);
+ samplePos = vec2(x + 2.0 * xScale, y + 2.0 * yScale);
+ zTmp =readDepth(samplePos);
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
zsum += coefZ;
- sum += coefZ* texture2D( m_SSAOMap, sample);
+ sum += coefZ* texture2D( m_SSAOMap, samplePos);
return sum / zsum;
@@ -124,4 +124,4 @@ vec4 getColor(vec4 color){
void main(){
gl_FragColor = getColor(convolutionFilter());
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md
index f5a1892cab..2314876d6d 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md
+++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md
@@ -14,8 +14,8 @@ MaterialDef SSAOBlur {
}
Technique {
- VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
- FragmentShader GLSL150 GLSL120: Common/MatDefs/SSAO/ssaoBlur.frag
+ VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
+ FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/SSAO/ssaoBlur.frag
WorldParameters {
WorldViewMatrix
@@ -28,4 +28,4 @@ MaterialDef SSAOBlur {
RESOLVE_DEPTH_MS : NumSamplesDepth
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/Textures/water_normalmap.dds b/jme3-effects/src/main/resources/Common/MatDefs/Water/Textures/water_normalmap.dds
index 13582e148c..529b8327b4 100644
Binary files a/jme3-effects/src/main/resources/Common/MatDefs/Water/Textures/water_normalmap.dds and b/jme3-effects/src/main/resources/Common/MatDefs/Water/Textures/water_normalmap.dds differ
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.frag b/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.frag
index c52a8d6921..d97e23dcb0 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.frag
+++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.frag
@@ -48,9 +48,8 @@ uniform vec3 m_Center;
uniform float m_Radius;
#endif
-
-vec2 scale = vec2(m_WaveScale, m_WaveScale);
-float refractionScale = m_WaveScale;
+vec2 scale; // = vec2(m_WaveScale, m_WaveScale);
+float refractionScale; // = m_WaveScale;
// Modifies 4 sampled normals. Increase first values to have more
// smaller "waves" or last to have more bigger "waves"
@@ -62,8 +61,18 @@ const float visibility = 3.0;
// foam intensity
uniform float m_FoamIntensity ;
+vec2 m_FrustumNearFar; //=vec2(1.0,m_UnderWaterFogDistance);
+const float LOG2 = 1.442695;
+
+
varying vec2 texCoord;
+void setGlobals(){
+scale = vec2(m_WaveScale, m_WaveScale);
+refractionScale = m_WaveScale;
+m_FrustumNearFar=vec2(1.0,m_UnderWaterFogDistance);
+}
+
mat3 MatrixInverse(in mat3 inMatrix){
float det = dot(cross(inMatrix[0], inMatrix[1]), inMatrix[2]);
mat3 T = transpose(inMatrix);
@@ -119,9 +128,6 @@ float fresnelTerm(in vec3 normal,in vec3 eyeVec){
return saturate(fresnel * (1.0 - saturate(m_R0)) + m_R0 - m_RefractionStrength);
}
-vec2 m_FrustumNearFar=vec2(1.0,m_UnderWaterFogDistance);
-const float LOG2 = 1.442695;
-
vec4 underWater(int sampleNum){
@@ -225,7 +231,7 @@ vec4 underWater(int sampleNum){
#endif
float fogDepth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - sceneDepth* (m_FrustumNearFar.y-m_FrustumNearFar.x));
- float fogIntensity= 18 * m_WaterTransparency;
+ float fogIntensity= 18.0 * m_WaterTransparency;
fogFactor = exp2( -fogIntensity * fogIntensity * fogDepth * fogDepth * LOG2 );
fogFactor = clamp(fogFactor, 0.0, 1.0);
color =mix(m_DeepWaterColor.rgb,color,fogFactor);
@@ -284,7 +290,7 @@ vec4 main_multiSample(int sampleNum){
samples = 10;
#endif
- float biasFactor = 1.0 / samples;
+ float biasFactor = 1.0 / float(samples);
for (int i = 0; i < samples; i++){
texC = (surfacePoint.xz + eyeVecNorm.xz * biasFactor) * scale + m_Time * 0.03 * m_WindDirection;
@@ -344,7 +350,7 @@ vec4 main_multiSample(int sampleNum){
normal = normalize(normal0a * normalModifier.x + normal1a * normalModifier.y +normal2a * normalModifier.z + normal3a * normalModifier.w);
- #if __VERSION__ >= 130
+ #if __VERSION__ >= 130 && !defined GL_ES
// XXX: Here's another way to fix the terrain edge issue,
// But it requires GLSL 1.3 and still looks kinda incorrect
// around edges
@@ -435,13 +441,14 @@ vec4 main_multiSample(int sampleNum){
}
void main(){
+ setGlobals();
#ifdef RESOLVE_MS
vec4 color = vec4(0.0);
for (int i = 0; i < m_NumSamples; i++){
color += main_multiSample(i);
}
- gl_FragColor = color / m_NumSamples;
+ gl_FragColor = color / float(m_NumSamples);
#else
gl_FragColor = main_multiSample(0);
#endif
-}
\ No newline at end of file
+}
diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md
index b75bd2c45f..49c5a06e53 100644
--- a/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md
+++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md
@@ -51,8 +51,8 @@ MaterialDef Advanced Water {
}
Technique {
- VertexShader GLSL150 GLSL120 : Common/MatDefs/Post/Post.vert
- FragmentShader GLSL150 GLSL120: Common/MatDefs/Water/Water.frag
+ VertexShader GLSL310 GLSL300 GLSL150 GLSL120 : Common/MatDefs/Post/Post.vert
+ FragmentShader GLSL310 GLSL300 GLSL150 GLSL120: Common/MatDefs/Water/Water.frag
WorldParameters {
ViewProjectionMatrixInverse
@@ -72,4 +72,4 @@ MaterialDef Advanced Water {
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/java/jme3test/animation/TestIssue1138.java b/jme3-examples/src/main/java/jme3test/animation/TestIssue1138.java
new file mode 100644
index 0000000000..ac390aaf51
--- /dev/null
+++ b/jme3-examples/src/main/java/jme3test/animation/TestIssue1138.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jme3test.animation;
+
+import com.jme3.anim.AnimComposer;
+import com.jme3.anim.Joint;
+import com.jme3.anim.SkinningControl;
+import com.jme3.app.SimpleApplication;
+import com.jme3.light.AmbientLight;
+import com.jme3.math.Vector3f;
+import com.jme3.scene.Node;
+
+/**
+ * Test case for JME issue #1138: Elephant's legUp animation sets Joint
+ * translation to NaN.
+ *
+ * If successful, the animation cycle will complete without throwing an
+ * IllegalStateException.
+ *
+ * @author Stephen Gold
+ */
+public class TestIssue1138 extends SimpleApplication {
+
+ SkinningControl sControl;
+
+ public static void main(String... argv) {
+ new TestIssue1138().start();
+ }
+
+ @Override
+ public void simpleInitApp() {
+ Node cgModel = (Node) assetManager.loadModel(
+ "Models/Elephant/Elephant.mesh.xml");
+ rootNode.attachChild(cgModel);
+ cgModel.rotate(0f, -1f, 0f);
+ cgModel.scale(0.04f);
+
+ AnimComposer composer = cgModel.getControl(AnimComposer.class);
+ composer.setCurrentAction("legUp");
+ sControl = cgModel.getControl(SkinningControl.class);
+
+ AmbientLight light = new AmbientLight();
+ rootNode.addLight(light);
+ }
+
+ @Override
+ public void simpleUpdate(float tpf) {
+ for (Joint joint : sControl.getArmature().getJointList()) {
+ Vector3f translation = joint.getLocalTranslation();
+ if (!Vector3f.isValidVector(translation)) {
+ String msg = "Invalid translation for joint " + joint.getName();
+ throw new IllegalStateException(msg);
+ }
+ }
+ }
+}
diff --git a/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java b/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java
index b6517c9d2b..3bbc316b4e 100644
--- a/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java
+++ b/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java
@@ -64,7 +64,10 @@ public void simpleInitApp() {
rootNode.attachChild(geom);
System.out.println("Attaching test state.");
- stateManager.attach(new TestState());
+ stateManager.attach(new TestState());
+
+ System.out.println("Attaching test state with an ID.");
+ stateManager.attach(new TestState("Test ID"));
}
@Override
@@ -74,51 +77,64 @@ public void simpleUpdate(float tpf) {
System.out.println("Detaching test state.");
stateManager.detach(stateManager.getState(TestState.class));
System.out.println("Done");
- }
+ }
+
+ if( stateManager.hasState("Test ID") ) {
+ System.out.println("Detaching test state with an ID.");
+ stateManager.detach(stateManager.getState("Test ID", TestState.class));
+ System.out.println("Done");
+ }
}
public class TestState extends AbstractAppState {
+ public TestState() {
+ }
+
+ public TestState( String id ) {
+ super(id);
+ }
+
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
- System.out.println("Initialized");
+ System.out.println("Initialized, id:" + getId());
}
@Override
public void stateAttached(AppStateManager stateManager) {
super.stateAttached(stateManager);
- System.out.println("Attached");
+ System.out.println("Attached, id:" + getId());
}
@Override
public void update(float tpf) {
super.update(tpf);
- System.out.println("update");
+ System.out.println("update, id:" + getId());
}
@Override
public void render(RenderManager rm) {
super.render(rm);
- System.out.println("render");
+ System.out.println("render, id:" + getId());
}
@Override
public void postRender() {
super.postRender();
- System.out.println("postRender");
+ System.out.println("postRender, id:" + getId());
}
@Override
public void stateDetached(AppStateManager stateManager) {
super.stateDetached(stateManager);
- System.out.println("Detached");
+ System.out.println("Detached, id:" + getId());
}
@Override
public void cleanup() {
super.cleanup();
- System.out.println("Cleanup");
+ System.out.println("Cleanup, id:" + getId());
}
}
diff --git a/jme3-examples/src/main/java/jme3test/bullet/shape/TestGimpactShape.java b/jme3-examples/src/main/java/jme3test/bullet/shape/TestGimpactShape.java
index 3c919268a2..484f0f1774 100644
--- a/jme3-examples/src/main/java/jme3test/bullet/shape/TestGimpactShape.java
+++ b/jme3-examples/src/main/java/jme3test/bullet/shape/TestGimpactShape.java
@@ -106,7 +106,7 @@ public class TestGimpactShape extends SimpleApplication {
public static void main(String[] args) {
test = new TestGimpactShape();
test.setSettings(new AppSettings(true));
- test.settings.setFrameRate(60);
+ test.settings.setVSync(true);
if (SKIP_SETTINGS) {
test.settings.setWidth(1920);
test.settings.setHeight(1150);
@@ -117,6 +117,7 @@ public static void main(String[] args) {
@Override
public void simpleInitApp() {
+ test = this;
getCamera().setLocation(new Vector3f(40, 30, 160));
getCamera().lookAt(new Vector3f(40, -5, 0), Vector3f.UNIT_Y);
getFlyByCamera().setMoveSpeed(25);
diff --git a/jme3-examples/src/main/java/jme3test/gui/TestRtlBitmapText.java b/jme3-examples/src/main/java/jme3test/gui/TestRtlBitmapText.java
new file mode 100644
index 0000000000..ed65c4a071
--- /dev/null
+++ b/jme3-examples/src/main/java/jme3test/gui/TestRtlBitmapText.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009-2019 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jme3test.gui;
+
+import com.jme3.app.SimpleApplication;
+import com.jme3.font.BitmapFont;
+import com.jme3.font.BitmapText;
+import com.jme3.font.LineWrapMode;
+import com.jme3.font.Rectangle;
+
+/**
+ * Test case for JME issue #1158: BitmapText right to left line wrapping not work
+ */
+public class TestRtlBitmapText extends SimpleApplication {
+
+ // A right to left text.
+ private String text = ".text left to right test a is This";
+
+ public static void main(String[] args) {
+ TestRtlBitmapText app = new TestRtlBitmapText();
+ app.start();
+ }
+
+ @Override
+ public void simpleInitApp() {
+ BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
+ // A right to left BitmapText
+ BitmapText txt = new BitmapText(fnt, true);
+ txt.setBox(new Rectangle(0, 0, 150, 0));
+ txt.setLineWrapMode(LineWrapMode.Word);
+ txt.setAlignment(BitmapFont.Align.Right);
+ txt.setText(text);
+ txt.setLocalTranslation(cam.getWidth() / 2, cam.getHeight() / 2, 0);
+ guiNode.attachChild(txt);
+ }
+}
diff --git a/jme3-examples/src/main/java/jme3test/terrain/TerrainTestCollision.java b/jme3-examples/src/main/java/jme3test/terrain/TerrainTestCollision.java
index 6822251ba7..faa67fd137 100644
--- a/jme3-examples/src/main/java/jme3test/terrain/TerrainTestCollision.java
+++ b/jme3-examples/src/main/java/jme3test/terrain/TerrainTestCollision.java
@@ -64,6 +64,9 @@
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Creates a terrain object and a collision node to go with it. Then
* drops several balls from the sky that collide with the terrain
@@ -83,7 +86,7 @@ public class TerrainTestCollision extends SimpleApplication {
protected BitmapText hintText;
PointLight pl;
Geometry lightMdl;
- Geometry collisionMarker;
+ List collisionMarkers;
private BulletAppState bulletAppState;
Geometry collisionSphere;
Geometry collisionBox;
@@ -103,6 +106,7 @@ public void initialize() {
@Override
public void simpleInitApp() {
+ collisionMarkers = new ArrayList<>();
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
@@ -142,6 +146,8 @@ public void simpleInitApp() {
terrain.setLocked(false); // unlock it so we can edit the height
rootNode.attachChild(terrain);
+ // if set to false, only the first collision is returned and collision is slightly faster.
+ terrain.setSupportMultipleCollisions(true);
/**
* Create PhysicsRigidBodyControl for collision
@@ -227,15 +233,19 @@ public void update() {
super.update();
}
- private void createCollisionMarker() {
- Sphere s = new Sphere(6, 6, 1);
- collisionMarker = new Geometry("collisionMarker");
- collisionMarker.setMesh(s);
- Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
- mat.setColor("Color", ColorRGBA.Orange);
- collisionMarker.setMaterial(mat);
- rootNode.attachChild(collisionMarker);
+ private void createCollisionMarkers(int num) {
+ for (int i = 0; i < num; i++) {
+ Sphere s = new Sphere(6, 6, 1);
+ Geometry collisionMarker = new Geometry("collisionMarker");
+ collisionMarker.setMesh(s);
+ Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
+ mat.setColor("Color", i == 0 ? ColorRGBA.Orange : ColorRGBA.Blue);
+ collisionMarker.setMaterial(mat);
+ rootNode.attachChild(collisionMarker);
+ collisionMarkers.add(collisionMarker);
+ }
}
+
private ActionListener actionListener = new ActionListener() {
public void onAction(String binding, boolean keyPressed, float tpf) {
@@ -247,24 +257,35 @@ public void onAction(String binding, boolean keyPressed, float tpf) {
terrain.setMaterial(matRock);
}
} else if (binding.equals("shoot") && !keyPressed) {
-
Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f);
Vector3f direction = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.3f);
direction.subtractLocal(origin).normalizeLocal();
-
Ray ray = new Ray(origin, direction);
CollisionResults results = new CollisionResults();
- int numCollisions = terrain.collideWith(ray, results);
- if (numCollisions > 0) {
- CollisionResult hit = results.getClosestCollision();
- if (collisionMarker == null) {
- createCollisionMarker();
+
+ if (terrain.collideWith(ray, results) > 0) {
+ CollisionResult hit = results.getClosestCollision(); // sorts the collection before printing
+ printCollisions(results);
+
+ // Remove old markers.
+ for (Geometry g: collisionMarkers) {
+ g.removeFromParent();
}
+ collisionMarkers.clear();
+
+ createCollisionMarkers(results.size());
+
+ // Position Closest Collision
Vector2f loc = new Vector2f(hit.getContactPoint().x, hit.getContactPoint().z);
float height = terrain.getHeight(loc);
- System.out.println("collide " + hit.getContactPoint() + ", height: " + height + ", distance: " + hit.getDistance());
- collisionMarker.setLocalTranslation(new Vector3f(hit.getContactPoint().x, height, hit.getContactPoint().z));
+ System.out.println("Closest Collision: " + hit.getContactPoint() + ", height: " + height + ", distance: " + hit.getDistance());
+ collisionMarkers.get(0).setLocalTranslation(new Vector3f(hit.getContactPoint().x, height, hit.getContactPoint().z));
+
+ // Position Rest: When getClosestCollision has been called, the results are sorted, and thus 0 is closest.
+ for (int i = 1; i < results.size(); i++) {
+ collisionMarkers.get(i).setLocalTranslation(results.getCollision(i).getContactPoint());
+ }
}
} else if (binding.equals("cameraDown") && !keyPressed) {
getCamera().lookAtDirection(new Vector3f(0, -1, 0), Vector3f.UNIT_Y);
@@ -302,4 +323,14 @@ private void testCollision(Vector3f oldLoc) {
selectedCollisionObject.setLocalTranslation(oldLoc);
}
}
+
+ private void printCollisions(CollisionResults cr) {
+ System.out.println("================ Collision Results ================");
+ for (int i = 0; i < cr.size(); i++) {
+ CollisionResult res = cr.getCollision(i);
+ System.out.println("Result " + i);
+ System.out.println("\t\t" + res.toString());
+ }
+ System.out.println("================ END Collision Results ================");
+ }
}
diff --git a/jme3-examples/src/main/java/jme3test/texture/TestTexture3D.java b/jme3-examples/src/main/java/jme3test/texture/TestTexture3D.java
index a7e553a9a1..1e151bf741 100644
--- a/jme3-examples/src/main/java/jme3test/texture/TestTexture3D.java
+++ b/jme3-examples/src/main/java/jme3test/texture/TestTexture3D.java
@@ -128,4 +128,4 @@ private Texture getTexture() throws IOException {
data.add(bb);
return new Texture3D(new Image(Format.RGB8, 10, 10, 10, data, null, ColorSpace.Linear));
}
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/java/jme3test/texture/TestTextureArray.java b/jme3-examples/src/main/java/jme3test/texture/TestTextureArray.java
index 391e4efcc6..1757c021bd 100644
--- a/jme3-examples/src/main/java/jme3test/texture/TestTextureArray.java
+++ b/jme3-examples/src/main/java/jme3test/texture/TestTextureArray.java
@@ -84,4 +84,4 @@ public static void main(String[] args)
app.start();
}
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/java/jme3test/texture/TestTextureArrayCompressed.java b/jme3-examples/src/main/java/jme3test/texture/TestTextureArrayCompressed.java
index 2187c58d87..738f4b94c2 100644
--- a/jme3-examples/src/main/java/jme3test/texture/TestTextureArrayCompressed.java
+++ b/jme3-examples/src/main/java/jme3test/texture/TestTextureArrayCompressed.java
@@ -31,8 +31,8 @@ public void simpleInitApp()
}
- Texture tex1 = assetManager.loadTexture( "Textures/Terrain/Pond/Pond.dds");
- Texture tex2 = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.dds");
+ Texture tex1 = assetManager.loadTexture( "Textures/Terrain/Pond/Pond_dxt5.dds");
+ Texture tex2 = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_dxt5.dds");
List images = new ArrayList();
images.add(tex1.getImage());
images.add(tex2.getImage());
@@ -84,4 +84,4 @@ public static void main(String[] args)
app.start();
}
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.frag b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.frag
index 355cf60928..4b888e81d8 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.frag
+++ b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.frag
@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
#extension GL_EXT_texture_array : enable
// #extension GL_EXT_gpu_shader4 : enable
@@ -8,7 +10,7 @@ uniform vec4 m_Color;
#endif
#ifdef HAS_COLORMAP
- #if !defined(GL_EXT_texture_array)
+ #if !defined(GL_EXT_texture_array) && __VERSION__ < 130
#error Texture arrays are not supported, but required for this shader.
#endif
@@ -54,4 +56,4 @@ void main(){
#endif
gl_FragColor = color;
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.j3md b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.j3md
index 6a3219e602..bcbee23d89 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.j3md
+++ b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.j3md
@@ -14,8 +14,8 @@ MaterialDef Unshaded {
}
Technique {
- VertexShader GLSL100: jme3test/texture/UnshadedArray.vert
- FragmentShader GLSL100: jme3test/texture/UnshadedArray.frag
+ VertexShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.vert
+ FragmentShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -32,8 +32,8 @@ MaterialDef Unshaded {
Technique PreNormalPass {
- VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert
- FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag
+ VertexShader GLSL300 GLSL100 : Common/MatDefs/SSAO/normal.vert
+ FragmentShader GLSL300 GLSL100 : Common/MatDefs/SSAO/normal.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -50,8 +50,8 @@ MaterialDef Unshaded {
Technique Glow {
- VertexShader GLSL100: Cjme3test/texture/UnshadedArray.vert
- FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag
+ VertexShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.vert
+ FragmentShader GLSL300 GLSL100: Common/MatDefs/Light/Glow.frag
WorldParameters {
WorldViewProjectionMatrix
@@ -63,4 +63,4 @@ MaterialDef Unshaded {
HAS_COLORMAP // Must be passed so that Unshaded.vert exports texCoord.
}
}
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.vert b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.vert
index 9d1153c3d4..3f85e3063b 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.vert
+++ b/jme3-examples/src/main/resources/jme3test/texture/UnshadedArray.vert
@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
uniform mat4 g_WorldViewProjectionMatrix;
attribute vec3 inPosition;
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3D.frag b/jme3-examples/src/main/resources/jme3test/texture/tex3D.frag
index 55862acf93..2e811ad03b 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3D.frag
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3D.frag
@@ -1,7 +1,9 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
uniform sampler3D m_Texture;
varying vec3 texCoord;
void main(){
gl_FragColor= texture3D(m_Texture,texCoord);
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3D.j3md b/jme3-examples/src/main/resources/jme3test/texture/tex3D.j3md
index 1ba2605948..61b35c99aa 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3D.j3md
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3D.j3md
@@ -5,8 +5,8 @@ MaterialDef My MaterialDef {
}
Technique {
- VertexShader GLSL100: jme3test/texture/tex3D.vert
- FragmentShader GLSL100: jme3test/texture/tex3D.frag
+ VertexShader GLSL300 GLSL100: jme3test/texture/tex3D.vert
+ FragmentShader GLSL300 GLSL100: jme3test/texture/tex3D.frag
WorldParameters {
WorldViewProjectionMatrix
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3D.vert b/jme3-examples/src/main/resources/jme3test/texture/tex3D.vert
index f91b7b3097..4681a36250 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3D.vert
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3D.vert
@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
uniform mat4 g_WorldViewProjectionMatrix;
attribute vec3 inTexCoord;
@@ -8,4 +10,4 @@ varying vec3 texCoord;
void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);
texCoord=inTexCoord;
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.frag b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.frag
index e70bc5b25a..9664f996a4 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.frag
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.frag
@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
uniform sampler3D m_Texture;
uniform int m_Rows;
uniform float m_InvDepth;
@@ -12,4 +14,4 @@ void main(){
vec3 texC = vec3(fract(texCoord.x),fract(texCoord.y),(depthy * rows + depthx) * m_InvDepth);
gl_FragColor = texture3D(m_Texture, texC);
-}
\ No newline at end of file
+}
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.j3md b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.j3md
index a42bd381ed..ee00681d34 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.j3md
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.j3md
@@ -7,8 +7,8 @@ MaterialDef Tex3DThumb {
}
Technique {
- VertexShader GLSL100: jme3test/texture/tex3DThumb.vert
- FragmentShader GLSL100: jme3test/texture/tex3DThumb.frag
+ VertexShader GLSL300 GLSL100: jme3test/texture/tex3DThumb.vert
+ FragmentShader GLSL300 GLSL100: jme3test/texture/tex3DThumb.frag
WorldParameters {
WorldViewProjectionMatrix
diff --git a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.vert b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.vert
index 6d27bc030c..2514cb532c 100644
--- a/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.vert
+++ b/jme3-examples/src/main/resources/jme3test/texture/tex3DThumb.vert
@@ -1,3 +1,5 @@
+#import "Common/ShaderLib/GLSLCompat.glsllib"
+
uniform mat4 g_WorldViewProjectionMatrix;
attribute vec2 inTexCoord;
@@ -8,4 +10,4 @@ varying vec2 texCoord;
void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);
texCoord=inTexCoord;
-}
\ No newline at end of file
+}
diff --git a/jme3-lwjgl3/build.gradle b/jme3-lwjgl3/build.gradle
index 442aa091e8..324c027b4b 100644
--- a/jme3-lwjgl3/build.gradle
+++ b/jme3-lwjgl3/build.gradle
@@ -2,7 +2,7 @@ if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
-def lwjglVersion = '3.2.1'
+def lwjglVersion = '3.2.3'
sourceCompatibility = '1.8'
diff --git a/jme3-networking/src/main/java/com/jme3/network/base/ConnectorAdapter.java b/jme3-networking/src/main/java/com/jme3/network/base/ConnectorAdapter.java
index 6f4935f8fb..100747ffd7 100644
--- a/jme3-networking/src/main/java/com/jme3/network/base/ConnectorAdapter.java
+++ b/jme3-networking/src/main/java/com/jme3/network/base/ConnectorAdapter.java
@@ -65,6 +65,7 @@ public class ConnectorAdapter extends Thread
private MessageListener