From 2e58f2774cb11b69cc952f781abea082482d55d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wei=C3=9F?= Date: Wed, 28 Sep 2016 08:19:04 +0200 Subject: [PATCH 01/21] #503 fixed --- .../src/main/java/com/jme3/texture/FrameBuffer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 e5755c595..4c7a813ee 100644 --- a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java +++ b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java @@ -510,14 +510,17 @@ public class FrameBuffer extends NativeObject { } /** - * @return The first color buffer attached to this FrameBuffer, or null + * @return The color buffer with the index set by {@link #setTargetIndex(int), or null * if no color buffers are attached. + * If MRT is disabled, the first color buffer is returned. */ public RenderBuffer getColorBuffer() { if (colorBufs.isEmpty()) return null; - - return colorBufs.get(0); + if (colorBufIndex<0 || colorBufIndex>=colorBufs.size()) { + return colorBufs.get(0); + } + return colorBufs.get(colorBufIndex); } /** From cf6951af349287e2c0c1cfa5030c194c4cba9202 Mon Sep 17 00:00:00 2001 From: Nehon Date: Mon, 3 Oct 2016 23:31:00 +0200 Subject: [PATCH 02/21] MikktSpace tangent generator now properly generates the BindPoseTangent buffer when necessary --- .../jme3/util/TangentBinormalGenerator.java | 18 +----------- .../main/java/com/jme3/util/TangentUtils.java | 29 +++++++++++++++++++ .../MikktspaceTangentGenerator.java | 7 +++-- 3 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 jme3-core/src/main/java/com/jme3/util/TangentUtils.java diff --git a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java index 5e85378ff..ac6b05a8c 100644 --- a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java @@ -226,23 +226,7 @@ public class TangentBinormalGenerator { processTriangleData(mesh, vertices, approxTangents,splitMirrored); //if the mesh has a bind pose, we need to generate the bind pose for the tangent buffer - if (mesh.getBuffer(Type.BindPosePosition) != null) { - - VertexBuffer tangents = mesh.getBuffer(Type.Tangent); - if (tangents != null) { - VertexBuffer bindTangents = new VertexBuffer(Type.BindPoseTangent); - bindTangents.setupData(Usage.CpuOnly, - 4, - Format.Float, - BufferUtils.clone(tangents.getData())); - - if (mesh.getBuffer(Type.BindPoseTangent) != null) { - mesh.clearBuffer(Type.BindPoseTangent); - } - mesh.setBuffer(bindTangents); - tangents.setUsage(Usage.Stream); - } - } + TangentUtils.generateBindPoseTangentsIfNecessary(mesh); } public static void generate(Mesh mesh, boolean approxTangents) { diff --git a/jme3-core/src/main/java/com/jme3/util/TangentUtils.java b/jme3-core/src/main/java/com/jme3/util/TangentUtils.java new file mode 100644 index 000000000..ae227896a --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/util/TangentUtils.java @@ -0,0 +1,29 @@ +package com.jme3.util; + +import com.jme3.scene.*; + +/** + * Created by Nehon on 03/10/2016. + */ +public class TangentUtils { + + public static void generateBindPoseTangentsIfNecessary(Mesh mesh){ + if (mesh.getBuffer(VertexBuffer.Type.BindPosePosition) != null) { + + VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); + if (tangents != null) { + VertexBuffer bindTangents = new VertexBuffer(VertexBuffer.Type.BindPoseTangent); + bindTangents.setupData(VertexBuffer.Usage.CpuOnly, + 4, + VertexBuffer.Format.Float, + BufferUtils.clone(tangents.getData())); + + if (mesh.getBuffer(VertexBuffer.Type.BindPoseTangent) != null) { + mesh.clearBuffer(VertexBuffer.Type.BindPoseTangent); + } + mesh.setBuffer(bindTangents); + tangents.setUsage(VertexBuffer.Usage.Stream); + } + } + } +} diff --git a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java index d3f6f4395..48bc41dd8 100644 --- a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java @@ -7,9 +7,9 @@ package com.jme3.util.mikktspace; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; -import com.jme3.scene.Geometry; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; +import com.jme3.scene.*; +import com.jme3.util.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -84,6 +84,7 @@ public class MikktspaceTangentGenerator { if(!genTangSpaceDefault(context)){ Logger.getLogger(MikktspaceTangentGenerator.class.getName()).log(Level.SEVERE, "Failed to generate tangents for geometry " + g.getName()); } + TangentUtils.generateBindPoseTangentsIfNecessary(g.getMesh()); } } From cd70630502ef15e08607e78fb40204cddea945e4 Mon Sep 17 00:00:00 2001 From: Nehon Date: Mon, 3 Oct 2016 23:39:07 +0200 Subject: [PATCH 03/21] Changed the order of import of the PBR.glsllib in the PBR material as it enables the texture lod extension and this fails on some GPU when it's not at the beginning of the shader. --- .../src/main/resources/Common/MatDefs/Light/PBRLighting.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0bd396383..852f66289 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -1,6 +1,6 @@ +#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Parallax.glsllib" -#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/Lighting.glsllib" From be6d2765e3ab4fa584996219bc928c5ffaaa044c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Bouquet?= Date: Thu, 6 Oct 2016 09:45:37 +0200 Subject: [PATCH 04/21] Added a setLocalTranslation and setLocalScale to the Bone class. Similarly to setLocalRotation it only works when userControl is set to true and fails otherwise. Also I changed how the value is set (with a set(...)) because it was assigning the passed parameter to the local instance of the transform. --- .../main/java/com/jme3/animation/Bone.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/animation/Bone.java b/jme3-core/src/main/java/com/jme3/animation/Bone.java index fcbacb337..3eae12137 100644 --- a/jme3-core/src/main/java/com/jme3/animation/Bone.java +++ b/jme3-core/src/main/java/com/jme3/animation/Bone.java @@ -812,13 +812,47 @@ public final class Bone implements Savable { output.writeSavableArrayList(children, "children", null); } + /** + * Sets the rotation of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param rot + */ public void setLocalRotation(Quaternion rot){ if (!userControl) { throw new IllegalStateException("User control must be on bone to allow user transforms"); } - this.localRot = rot; + this.localRot.set(rot); } - + + /** + * Sets the position of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param pos + */ + public void setLocalTranslation(Vector3f pos){ + if (!userControl) { + throw new IllegalStateException("User control must be on bone to allow user transforms"); + } + this.localPos.set(pos); + } + + /** + * Sets the scale of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param scale the scale to apply + */ + public void setLocalScale(Vector3f scale){ + if (!userControl) { + throw new IllegalStateException("User control must be on bone to allow user transforms"); + } + this.localScale.set(scale); + } + + /** + * returns true if this bone can be directly manipulated by the user. + * @see #setUserControl(boolean) + * @return + */ public boolean hasUserControl(){ return userControl; } From 9cf67b902e46dbc2e01f88cb3e8b28729730c5f4 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 9 Oct 2016 10:00:18 +0200 Subject: [PATCH 05/21] Fixed SpotLight constructor to properly compute the invSpotRange see https://github.com/jMonkeyEngine/jmonkeyengine/issues/563 --- jme3-core/src/main/java/com/jme3/light/SpotLight.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/light/SpotLight.java b/jme3-core/src/main/java/com/jme3/light/SpotLight.java index 636f1447f..70115bbc5 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -102,7 +102,7 @@ public class SpotLight extends Light { this(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } /** @@ -133,7 +133,7 @@ public class SpotLight extends Light { computeAngleParameters(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } /** @@ -158,7 +158,7 @@ public class SpotLight extends Light { computeAngleParameters(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } From 81830c414640085a1db3b4edcdaa9d683cfff8fa Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 9 Oct 2016 20:12:39 +0200 Subject: [PATCH 06/21] ShaderNodes now move all the declared extensions at the top of the generated shader source --- .../java/com/jme3/shader/ShaderGenerator.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/shader/ShaderGenerator.java b/jme3-core/src/main/java/com/jme3/shader/ShaderGenerator.java index 3e3677c9c..db3878afd 100644 --- a/jme3-core/src/main/java/com/jme3/shader/ShaderGenerator.java +++ b/jme3-core/src/main/java/com/jme3/shader/ShaderGenerator.java @@ -38,6 +38,7 @@ import com.jme3.material.Technique; import com.jme3.material.TechniqueDef; import com.jme3.shader.Shader.ShaderType; import java.util.List; +import java.util.regex.*; /** * This class is the base for a shader generator using the ShaderNodes system, @@ -59,7 +60,11 @@ public abstract class ShaderGenerator { /** * the technique def to use for the shader generation */ - protected TechniqueDef techniqueDef = null; + protected TechniqueDef techniqueDef = null; + /** + * Extension pattern + */ + Pattern extensions = Pattern.compile("(#extension.*\\s+)"); /** * Build a shaderGenerator @@ -142,7 +147,23 @@ public abstract class ShaderGenerator { sourceDeclaration.append(source); - return sourceDeclaration.toString(); + return moveExtensionsUp(sourceDeclaration); + } + + /** + * parses the source and moves all the extensions at the top of the shader source as having extension declarations + * in the middle of a shader is against the specs and not supported by all drivers. + * @param sourceDeclaration + * @return + */ + private String moveExtensionsUp(StringBuilder sourceDeclaration) { + Matcher m = extensions.matcher( sourceDeclaration.toString()); + StringBuilder finalSource = new StringBuilder(); + while(m.find()){ + finalSource.append(m.group()); + } + finalSource.append(m.replaceAll("")); + return finalSource.toString(); } /** From ad6da79ad11f3f1c4171437d00d07ae214f09d07 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 30 Oct 2016 09:45:23 +0100 Subject: [PATCH 07/21] Fixed the link to the paper for convertHalfToFloat --- jme3-core/src/main/java/com/jme3/math/FastMath.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/math/FastMath.java b/jme3-core/src/main/java/com/jme3/math/FastMath.java index 4f1a7feed..5ca65bb7f 100644 --- a/jme3-core/src/main/java/com/jme3/math/FastMath.java +++ b/jme3-core/src/main/java/com/jme3/math/FastMath.java @@ -942,8 +942,7 @@ final public class FastMath { * Converts a single precision (32 bit) floating point value * into half precision (16 bit). * - *

Source: - * http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
broken link + *

Source: Date: Fri, 4 Nov 2016 20:08:44 +0100 Subject: [PATCH 12/21] Changed the minimum value of a float when converting it to half float. It was 5.96046E-8f and it's now 3.054738E-5f. This values seems to be the lowest one before 0 when converting back half to float. This issue has been revealed in this post https://hub.jmonkeyengine.org/t/pbr-nan-to-half-conversion-errors/37219 The bad minimum was causing erratic data being wrote to the texture when the value was very close to 0, and causing the glitches and even crashes when color values were given as Float.Infinity or Float.NaN. --- jme3-core/src/main/java/com/jme3/math/FastMath.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/math/FastMath.java b/jme3-core/src/main/java/com/jme3/math/FastMath.java index 5ca65bb7f..c1c3fa8a9 100644 --- a/jme3-core/src/main/java/com/jme3/math/FastMath.java +++ b/jme3-core/src/main/java/com/jme3/math/FastMath.java @@ -981,9 +981,9 @@ final public class FastMath { return 0x7bff; } else if (flt < -65504f) { return (short) (0x7bff | 0x8000); - } else if (flt > 0f && flt < 5.96046E-8f) { + } else if (flt > 0f && flt < 3.054738E-5f) { return 0x0001; - } else if (flt < 0f && flt > -5.96046E-8f) { + } else if (flt < 0f && flt > -3.054738E-5f) { return (short) 0x8001; } From af11f870f1c40f00a3c4fa30c07951498dcd6ae9 Mon Sep 17 00:00:00 2001 From: TehLeo Date: Sat, 12 Nov 2016 18:47:09 +0100 Subject: [PATCH 13/21] Update GL3.java --- .../java/com/jme3/renderer/opengl/GL3.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java index 1fbad5c2d..9b01e46a5 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java @@ -54,6 +54,34 @@ public interface GL3 extends GL2 { public static final int GL_TEXTURE_SWIZZLE_B = 0x8E44; public static final int GL_TEXTURE_SWIZZLE_G = 0x8E43; public static final int GL_TEXTURE_SWIZZLE_R = 0x8E42; + public static final int GL_R8I = 33329; + public static final int GL_R8UI = 33330; + public static final int GL_R16I = 33331; + public static final int GL_R16UI = 33332; + public static final int GL_R32I = 33333; + public static final int GL_R32UI = 33334; + public static final int GL_RG8I = 33335; + public static final int GL_RG8UI = 33336; + public static final int GL_RG16I = 33337; + public static final int GL_RG16UI = 33338; + public static final int GL_RG32I = 33339; + public static final int GL_RG32UI = 33340; + public static final int GL_RGBA32UI = 36208; + public static final int GL_RGB32UI = 36209; + public static final int GL_RGBA16UI = 36214; + public static final int GL_RGB16UI = 36215; + public static final int GL_RGBA8UI = 36220; + public static final int GL_RGB8UI = 36221; + public static final int GL_RGBA32I = 36226; + public static final int GL_RGB32I = 36227; + public static final int GL_RGBA16I = 36232; + public static final int GL_RGB16I = 36233; + public static final int GL_RGBA8I = 36238; + public static final int GL_RGB8I = 36239; + public static final int GL_RED_INTEGER = 36244; + public static final int GL_RG_INTEGER = 33320; + public static final int GL_RGB_INTEGER = 36248; + public static final int GL_RGBA_INTEGER = 36249; public void glBindFragDataLocation(int param1, int param2, String param3); /// GL3+ public void glBindVertexArray(int param1); /// GL3+ From d90ee201da133d1f4a902621907d0b65da9b47b0 Mon Sep 17 00:00:00 2001 From: TehLeo Date: Sat, 12 Nov 2016 18:48:13 +0100 Subject: [PATCH 14/21] Update GLImageFormats.java --- .../jme3/renderer/opengl/GLImageFormats.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java index ab80b9e2a..f12bfd1bc 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java @@ -233,6 +233,37 @@ public final class GLImageFormats { formatComp(formatToGL, Format.ETC1, GLExt.GL_ETC1_RGB8_OES, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); } + // Integer formats + if(caps.contains(Caps.IntegerTexture)) { + format(formatToGL, Format.R8I, GL3.GL_R8I, GL3.GL_RED_INTEGER, GL.GL_BYTE); + format(formatToGL, Format.R8UI, GL3.GL_R8UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.R16I, GL3.GL_R16I, GL3.GL_RED_INTEGER, GL.GL_SHORT); + format(formatToGL, Format.R16UI, GL3.GL_R16UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_SHORT); + format(formatToGL, Format.R32I, GL3.GL_R32I, GL3.GL_RED_INTEGER, GL.GL_INT); + format(formatToGL, Format.R32UI, GL3.GL_R32UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_INT); + + format(formatToGL, Format.RG8I, GL3.GL_RG8I, GL3.GL_RG_INTEGER, GL.GL_BYTE); + format(formatToGL, Format.RG8UI, GL3.GL_RG8UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.RG16I, GL3.GL_RG16I, GL3.GL_RG_INTEGER, GL.GL_SHORT); + format(formatToGL, Format.RG16UI, GL3.GL_RG16UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_SHORT); + format(formatToGL, Format.RG32I, GL3.GL_RG32I, GL3.GL_RG_INTEGER, GL.GL_INT); + format(formatToGL, Format.RG32UI, GL3.GL_RG32UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_INT); + + format(formatToGL, Format.RGB8I, GL3.GL_RGB8I, GL3.GL_RGB_INTEGER, GL.GL_BYTE); + format(formatToGL, Format.RGB8UI, GL3.GL_RGB8UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.RGB16I, GL3.GL_RGB16I, GL3.GL_RGB_INTEGER, GL.GL_SHORT); + format(formatToGL, Format.RGB16UI, GL3.GL_RGB16UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_SHORT); + format(formatToGL, Format.RGB32I, GL3.GL_RGB32I, GL3.GL_RGB_INTEGER, GL.GL_INT); + format(formatToGL, Format.RGB32UI, GL3.GL_RGB32UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_INT); + + format(formatToGL, Format.RGBA8I, GL3.GL_RGBA8I, GL3.GL_RGBA_INTEGER, GL.GL_BYTE); + format(formatToGL, Format.RGBA8UI, GL3.GL_RGBA8UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.RGBA16I, GL3.GL_RGBA16I, GL3.GL_RGBA_INTEGER, GL.GL_SHORT); + format(formatToGL, Format.RGBA16UI, GL3.GL_RGBA16UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_SHORT); + format(formatToGL, Format.RGBA32I, GL3.GL_RGBA32I, GL3.GL_RGBA_INTEGER, GL.GL_INT); + format(formatToGL, Format.RGBA32UI, GL3.GL_RGBA32UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_INT); + } + return formatToGL; } } From 7693e785c2f6d98a0f09aab133cb854b190b985e Mon Sep 17 00:00:00 2001 From: TehLeo Date: Sat, 12 Nov 2016 18:50:05 +0100 Subject: [PATCH 15/21] Update Image.java --- .../src/main/java/com/jme3/texture/Image.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 91b80ad3e..39c7725c0 100644 --- a/jme3-core/src/main/java/com/jme3/texture/Image.java +++ b/jme3-core/src/main/java/com/jme3/texture/Image.java @@ -299,7 +299,33 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ { * * Requires {@link Caps#TextureCompressionETC1}. */ - ETC1(4, false, true, false); + ETC1(4, false, true, false), + + R8I(8), + R8UI(8), + R16I(16), + R16UI(16), + R32I(32), + R32UI(32), + RG8I(16), + RG8UI(16), + RG16I(32), + RG16UI(32), + RG32I(64), + RG32UI(64), + RGB8I(24), + RGB8UI(24), + RGB16I(48), + RGB16UI(48), + RGB32I(96), + RGB32UI(96), + RGBA8I(32), + RGBA8UI(32), + RGBA16I(64), + RGBA16UI(64), + RGBA32I(128), + RGBA32UI(128) + ; private int bpp; private boolean isDepth; From 85f1e6ab46e1b4c63397eaf7bbac5824e97d52ea Mon Sep 17 00:00:00 2001 From: TehLeo Date: Sat, 12 Nov 2016 18:51:14 +0100 Subject: [PATCH 16/21] Update GLRenderer.java --- .../src/main/java/com/jme3/renderer/opengl/GLRenderer.java | 4 ++++ 1 file changed, 4 insertions(+) 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 2052f91d2..18dde97c7 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 @@ -298,6 +298,10 @@ public final class GLRenderer implements Renderer { if (hasFloatTexture) { caps.add(Caps.FloatTexture); } + + // integer texture format extensions + if(hasExtension("GL_EXT_texture_integer") || caps.contains(Caps.OpenGL30)) + caps.add(Caps.IntegerTexture); if (hasExtension("GL_OES_depth_texture") || gl2 != null) { caps.add(Caps.DepthTexture); From 7ed61854dfb6421effe7c72c09d4e284bdc208a3 Mon Sep 17 00:00:00 2001 From: TehLeo Date: Sat, 12 Nov 2016 18:52:36 +0100 Subject: [PATCH 17/21] Update Caps.java --- jme3-core/src/main/java/com/jme3/renderer/Caps.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/Caps.java b/jme3-core/src/main/java/com/jme3/renderer/Caps.java index 9387b687e..4cf062be2 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Caps.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Caps.java @@ -201,7 +201,12 @@ public enum Caps { * Supports floating point & half textures (Format.RGB16F) */ FloatTexture, - + + /** + * Supports integer textures + */ + IntegerTexture, + /** * Supports floating point FBO color buffers (Format.RGB16F) */ From ed817507d421a1813ca022725661b1ed8db2df5a Mon Sep 17 00:00:00 2001 From: Paul Speed Date: Sun, 20 Nov 2016 07:14:49 -0500 Subject: [PATCH 18/21] Improved the "compare result changed" error message to include the most likely cause of the error. --- jme3-core/src/main/java/com/jme3/util/ListSort.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/util/ListSort.java b/jme3-core/src/main/java/com/jme3/util/ListSort.java index 8f61961ad..b88235f37 100644 --- a/jme3-core/src/main/java/com/jme3/util/ListSort.java +++ b/jme3-core/src/main/java/com/jme3/util/ListSort.java @@ -698,9 +698,11 @@ public class ListSort { System.arraycopy(arr, iterB, arr, dest, lengthB); // The last element of run A belongs at the end of the merge. arr[dest + lengthB] = tempArray[iterA]; - } else if(lengthA== 0){ + } else if(lengthA == 0){ throw new UnsupportedOperationException("Compare function result changed! " + - "Make sure you do not modify the scene from another thread!"); + "Make sure you do not modify the scene from" + + " another thread and that the comparisons are not based" + + " on NaN values."); } else {//Fail label System.arraycopy(tempArray, iterA, arr, dest, lengthA); } From 35de6d9fda1c87291a9b0bc93dd82abe740d86e4 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 20 Nov 2016 19:02:02 +0100 Subject: [PATCH 19/21] Fixed an issue where some occluders were wrongly culled out from the shadow map at very steep light angle, and when the view cam was almost align with light direction. --- .../java/com/jme3/shadow/DirectionalLightShadowRenderer.java | 2 +- jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java index 33adf1c09..196bfbe7c 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java @@ -145,7 +145,7 @@ public class DirectionalLightShadowRenderer extends AbstractShadowRenderer { float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f); ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points); - //shadowCam.setDirection(direction); + shadowCam.setFrustumFar(zFar); shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp()); shadowCam.update(); shadowCam.updateViewProjection(); diff --git a/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java b/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java index d97a354f9..51942cdac 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java +++ b/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java @@ -465,7 +465,7 @@ public class ShadowUtil { shadowCam.setProjectionMatrix(null); if (ortho) { - shadowCam.setFrustum(-1, 1, -1, 1, 1, -1); + shadowCam.setFrustum(-shadowCam.getFrustumFar(), shadowCam.getFrustumFar(), -1, 1, 1, -1); } // create transform to rotate points to viewspace From 11562f88cf03a166bda6c5d0f2a1b3d0129f21be Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 20 Nov 2016 23:55:06 +0100 Subject: [PATCH 20/21] Fixed shadow fade and zfar computation as it was breaking shadow border filtering. --- .../src/main/resources/Common/MatDefs/Shadow/PostShadow.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag index a2d191895..6d1cc7a5a 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag @@ -80,7 +80,7 @@ void main(){ #endif #ifdef FADE - shadow = max(0.0,mix(shadow,1.0,(shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)); + shadow = max(0.0, mix(shadow, 1.0, max(0.0, (shadowPosition - m_FadeInfo.x) * m_FadeInfo.y))); #endif shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity); From 86f6f040e3c0c6f2ee5736e16d3894a639abad2a Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Wed, 23 Nov 2016 21:05:20 -0500 Subject: [PATCH 21/21] Fix #550 --- jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java b/jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java index 3a99759d1..a9dfefca1 100644 --- a/jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java +++ b/jme3-core/src/main/java/com/jme3/scene/GeometryGroupNode.java @@ -9,9 +9,6 @@ package com.jme3.scene; public abstract class GeometryGroupNode extends Node { public static int getGeometryStartIndex(Geometry geom) { - if (geom.startIndex == -1) { - throw new AssertionError(); - } return geom.startIndex; }