From 704c3f1a10707626762fa8ceb93a05ee57216bbd Mon Sep 17 00:00:00 2001 From: David Bernard Date: Sun, 5 Jul 2015 11:38:32 +0200 Subject: [PATCH 1/4] enable MRT on gl3 --- .../src/main/java/com/jme3/renderer/opengl/GLRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 729f4e203..1b4907c60 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 @@ -401,7 +401,7 @@ public class GLRenderer implements Renderer { } } - if (hasExtension("GL_ARB_draw_buffers")) { + if (hasExtension("GL_ARB_draw_buffers") || gl3 != null) { limits.put(Limits.FrameBufferMrtAttachments, getInteger(GLExt.GL_MAX_DRAW_BUFFERS_ARB)); if (limits.get(Limits.FrameBufferMrtAttachments) > 1) { caps.add(Caps.FrameBufferMRT); From 568ee09d17a1d95aa31f97de1977d6ee419cfbfd Mon Sep 17 00:00:00 2001 From: David Bernard Date: Sun, 5 Jul 2015 11:39:10 +0200 Subject: [PATCH 2/4] add GLSL150 compatible Unshaded --- .../com/jme3/renderer/opengl/GLRenderer.java | 1 + .../Common/MatDefs/Misc/Unshaded.frag | 2 ++ .../Common/MatDefs/Misc/Unshaded.j3md | 25 ++++++++++++++++--- .../Common/MatDefs/Misc/Unshaded.vert | 1 + .../Common/ShaderLib/GLSL150Compat.glsllib | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) 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 1b4907c60..6d4e4abba 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 @@ -1080,6 +1080,7 @@ public class GLRenderer implements Renderer { if (linearizeSrgbImages) { stringBuf.append("#define SRGB 1\n"); } + stringBuf.append("#define ").append(source.getType().name().toUpperCase()).append("_SHADER 1\n"); stringBuf.append(source.getDefines()); stringBuf.append(source.getSource()); diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag index ce8219b6e..73df8d740 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.frag @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSL150Compat.glsllib" + #if defined(HAS_GLOWMAP) || defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) #define NEED_TEXCOORD1 #endif 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 aee284705..8dd6fc5ca 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md @@ -13,7 +13,7 @@ MaterialDef Unshaded { Color GlowColor // For instancing - Boolean UseInstancing + Boolean UseInstancing // For hardware skinning Int NumberOfBones @@ -54,8 +54,8 @@ MaterialDef Unshaded { } Technique { - VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/Misc/Unshaded.frag + VertexShader GLSL150: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL150: Common/MatDefs/Misc/Unshaded.frag WorldParameters { WorldViewProjectionMatrix @@ -76,6 +76,25 @@ MaterialDef Unshaded { } Technique { + VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL100: Common/MatDefs/Misc/Unshaded.frag + + WorldParameters { + WorldViewProjectionMatrix + ViewProjectionMatrix + ViewMatrix + } + + Defines { + INSTANCING : UseInstancing + SEPARATE_TEXCOORD : SeparateTexCoord + HAS_COLORMAP : ColorMap + HAS_LIGHTMAP : LightMap + HAS_VERTEXCOLOR : VertexColor + HAS_COLOR : Color + NUM_BONES : NumberOfBones + DISCARD_ALPHA : AlphaDiscardThreshold + } } Technique PreNormalPass { diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert index 63b05ef88..454708d92 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSL150Compat.glsllib" #import "Common/ShaderLib/Skinning.glsllib" #import "Common/ShaderLib/Instancing.glsllib" diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib index 336490696..87f07a3f5 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/GLSL150Compat.glsllib @@ -1,4 +1,4 @@ -#if _VERSION_ >= 150 +#if __VERSION__ >= 130 out vec4 outFragColor; # define texture1D texture # define texture2D texture From c7606ccff2527acc1b6495a87bc742646c030e07 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 12 Jul 2015 20:43:54 +0200 Subject: [PATCH 3/4] Fixed issue https://github.com/jMonkeyEngine/jmonkeyengine/issues/291 --- .../src/main/java/com/jme3/collision/bih/BIHTree.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java b/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java index 38a633e96..5db94b409 100644 --- a/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java +++ b/jme3-core/src/main/java/com/jme3/collision/bih/BIHTree.java @@ -48,6 +48,7 @@ import com.jme3.math.Vector3f; import com.jme3.scene.CollisionData; import com.jme3.scene.Mesh; import com.jme3.scene.Mesh.Mode; +import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.VirtualIndexBuffer; @@ -114,8 +115,13 @@ public class BIHTree implements CollisionData { bihSwapTmp = new float[9]; - FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData(); + VertexBuffer vBuffer = mesh.getBuffer(Type.Position); + if(vBuffer == null){ + throw new IllegalArgumentException("A mesh should at least contain a Position buffer"); + } IndexBuffer ib = mesh.getIndexBuffer(); + FloatBuffer vb = (FloatBuffer) vBuffer.getData(); + if (ib == null) { ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode()); } else if (mesh.getMode() != Mode.Triangles) { From 129faf00d70fe4eee104475a3ea02fdfa9e53e57 Mon Sep 17 00:00:00 2001 From: Nehon Date: Tue, 14 Jul 2015 09:41:55 +0200 Subject: [PATCH 4/4] Fixed warning when trying to find a srgb format for a Depth format. --- .../src/main/java/com/jme3/renderer/opengl/TextureUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java index a2f21ceaa..fb6032393 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java @@ -90,9 +90,11 @@ final class TextureUtil { } public GLImageFormat getImageFormatWithError(Format fmt, boolean isSrgb) { + //if the passed format is one kind of depth there isno point in getting the srgb format; + isSrgb = isSrgb && fmt != Format.Depth && fmt != Format.Depth16 && fmt != Format.Depth24 && fmt != Format.Depth24Stencil8 && fmt != Format.Depth32 && fmt != Format.Depth32F; GLImageFormat glFmt = getImageFormat(fmt, isSrgb); if (glFmt == null && isSrgb) { - glFmt = getImageFormat(fmt, false); + glFmt = getImageFormat(fmt, false); logger.log(Level.WARNING, "No sRGB format available for ''{0}''. Failling back to linear.", fmt); } if (glFmt == null) {