diff --git a/build.gradle b/build.gradle index 3a8665994..db97fb475 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,13 @@ buildscript { } } +allprojects { + repositories { + google() + jcenter() + } +} + apply plugin: 'base' apply from: file('version.gradle') diff --git a/jme3-android-examples/build.gradle b/jme3-android-examples/build.gradle index 023b662f0..17be807eb 100644 --- a/jme3-android-examples/build.gradle +++ b/jme3-android-examples/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 28 + buildToolsVersion "28.0.3" lintOptions { // Fix nifty gui referencing "java.awt" package. @@ -13,7 +13,7 @@ android { defaultConfig { applicationId "org.jmonkeyengine.jme3androidexamples" minSdkVersion 15 // Android 4.0.3 ICE CREAM SANDWICH - targetSdkVersion 22 // Android 5.1 LOLLIPOP + targetSdkVersion 28 // Android 9 PIE versionCode 1 versionName "1.0" // TODO: from settings.gradle } @@ -25,6 +25,11 @@ android { } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + sourceSets { main { java { @@ -42,7 +47,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:appcompat-v7:28.0.0' compile project(':jme3-core') compile project(':jme3-android') diff --git a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java index 907dd4e6a..0e2faeea3 100644 --- a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java +++ b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java @@ -62,15 +62,15 @@ public class JmeFragment extends AndroidHarnessFragment { public void onCreate(Bundle savedInstanceState) { Bundle bundle=getArguments(); - appClass = bundle.getString(SELECTED_APP_CLASS); + appClass = bundle.getString(MainActivity.SELECTED_APP_CLASS); // Log.d(this.getClass().getSimpleName(), "AppClass: " + appClass); - joystickEventsEnabled = bundle.getBoolean(ENABLE_JOYSTICK_EVENTS); + joystickEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS); // Log.d(this.getClass().getSimpleName(), "JoystickEventsEnabled: " + joystickEventsEnabled); - keyEventsEnabled = bundle.getBoolean(ENABLE_KEY_EVENTS); + keyEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_KEY_EVENTS); // Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled); - mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS); + mouseEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS); // Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled); - boolean verboseLogging = bundle.getBoolean(VERBOSE_LOGGING); + boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING); // Log.d(this.getClass().getSimpleName(), "VerboseLogging: " + verboseLogging); if (verboseLogging) { // Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info) diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java b/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java index 44e931104..ced4260ea 100644 --- a/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java +++ b/jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java @@ -34,6 +34,7 @@ package com.jme3.renderer.android; import android.opengl.*; import com.jme3.renderer.RendererException; import com.jme3.renderer.opengl.*; +import com.jme3.util.BufferUtils; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -41,7 +42,9 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; -public class AndroidGL implements GL, GLExt, GLFbo { +public class AndroidGL implements GL, GL2, GLES_30, GLExt, GLFbo { + + IntBuffer tmpBuff = BufferUtils.createIntBuffer(1); public void resetStats() { } @@ -361,7 +364,7 @@ public class AndroidGL implements GL, GLExt, GLFbo { } public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, ByteBuffer data) { - GLES20.glTexImage2D(target, level, format, width, height, 0, format, type, data); + GLES20.glTexImage2D(target, level, internalFormat, width, height, 0, format, type, data); } public void glTexParameterf(int target, int pname, float param) { @@ -449,7 +452,7 @@ public class AndroidGL implements GL, GLExt, GLFbo { } public void glBlitFramebufferEXT(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { - throw new UnsupportedOperationException("FBO blit not available on Android"); + GLES30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } public void glBufferData(int target, IntBuffer data, int usage) { @@ -461,31 +464,31 @@ public class AndroidGL implements GL, GLExt, GLFbo { } public void glDrawArraysInstancedARB(int mode, int first, int count, int primcount) { - throw new UnsupportedOperationException("Instancing not available on Android"); + GLES30.glDrawArraysInstanced(mode, first, count, primcount); } public void glDrawBuffers(IntBuffer bufs) { - throw new UnsupportedOperationException("MRT not available on Android"); + GLES30.glDrawBuffers(bufs.limit(), bufs); } public void glDrawElementsInstancedARB(int mode, int indices_count, int type, long indices_buffer_offset, int primcount) { - throw new UnsupportedOperationException("Instancing not available on Android"); + GLES30.glDrawElementsInstanced(mode, indices_count, type, (int)indices_buffer_offset, primcount); } public void glGetMultisample(int pname, int index, FloatBuffer val) { - throw new UnsupportedOperationException("Multisample renderbuffers not available on Android"); + GLES31.glGetMultisamplefv(pname, index, val); } public void glRenderbufferStorageMultisampleEXT(int target, int samples, int internalformat, int width, int height) { - throw new UnsupportedOperationException("Multisample renderbuffers not available on Android"); + GLES30.glRenderbufferStorageMultisample(target, samples, internalformat, width, height); } public void glTexImage2DMultisample(int target, int samples, int internalformat, int width, int height, boolean fixedsamplelocations) { - throw new UnsupportedOperationException("Multisample textures not available on Android"); + GLES31.glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations); } public void glVertexAttribDivisorARB(int index, int divisor) { - throw new UnsupportedOperationException("Instancing not available on Android"); + GLES30.glVertexAttribDivisor(index, divisor); } public void glBindFramebufferEXT(int param1, int param2) { @@ -564,6 +567,49 @@ public class AndroidGL implements GL, GLExt, GLFbo { @Override public void glFramebufferTextureLayerEXT(int target, int attachment, int texture, int level, int layer) { - throw new UnsupportedOperationException("OpenGL ES 2 does not support texture arrays"); + GLES30.glFramebufferTextureLayer(target, attachment, texture, level, layer); + } + + public void glAlphaFunc(int func, float ref) { + } + + public void glPointSize(float size) { + } + + public void glPolygonMode(int face, int mode) { + } + + // Wrapper to DrawBuffers as there's no DrawBuffer method in GLES + public void glDrawBuffer(int mode) { + tmpBuff.clear(); + tmpBuff.put(0, mode); + tmpBuff.rewind(); + glDrawBuffers(tmpBuff); + } + + public void glReadBuffer(int mode) { + GLES30.glReadBuffer(mode); } + + public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, + int border, ByteBuffer data) { + GLES30.glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, getLimitBytes(data), data); + } + + public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, + int height, int depth, int format, ByteBuffer data) { + GLES30.glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, getLimitBytes(data), data); + } + + public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, + int format, int type, ByteBuffer data) { + GLES30.glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data); + } + + public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, + int depth, int format, int type, ByteBuffer data) { + GLES30.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data); + } + } + diff --git a/jme3-android/src/main/java/com/jme3/system/android/AndroidConfigChooser.java b/jme3-android/src/main/java/com/jme3/system/android/AndroidConfigChooser.java index ba4c5a42e..4bccf537a 100644 --- a/jme3-android/src/main/java/com/jme3/system/android/AndroidConfigChooser.java +++ b/jme3-android/src/main/java/com/jme3/system/android/AndroidConfigChooser.java @@ -19,6 +19,7 @@ public class AndroidConfigChooser implements EGLConfigChooser { private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName()); protected AppSettings settings; private final static int EGL_OPENGL_ES2_BIT = 4; + private final static int EGL_OPENGL_ES3_BIT = 0x40; public AndroidConfigChooser(AppSettings settings) { this.settings = settings; @@ -140,12 +141,29 @@ public class AndroidConfigChooser implements EGLConfigChooser { int[] num_config = new int[1]; int[] configSpec = new int[]{ - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL10.EGL_NONE}; + boolean gles3=true; - if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) { - RendererUtil.checkEGLError(egl); - throw new AssertionError(); + // Try openGL ES 3 + try { + if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) { + RendererUtil.checkEGLError(egl); + gles3=false; + } + } catch (com.jme3.renderer.RendererException re) { + // it's just the device not supporting GLES3. Fallback to GLES2 + gles3=false; + } + + if(!gles3) + { + // Get back to openGL ES 2 + configSpec[1]=EGL_OPENGL_ES2_BIT; + if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) { + RendererUtil.checkEGLError(egl); + throw new AssertionError(); + } } int numConfigs = num_config[0]; diff --git a/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java b/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java index db185b002..d22995ef8 100644 --- a/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java +++ b/jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java @@ -53,6 +53,7 @@ import com.jme3.input.dummy.DummyKeyInput; import com.jme3.input.dummy.DummyMouseInput; import com.jme3.renderer.android.AndroidGL; import com.jme3.renderer.opengl.GL; +import com.jme3.renderer.opengl.GLES_30; import com.jme3.renderer.opengl.GLDebugES; import com.jme3.renderer.opengl.GLExt; import com.jme3.renderer.opengl.GLFbo; @@ -99,13 +100,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex * @return GLSurfaceView The newly created view */ public GLSurfaceView createView(Context context) { + ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + ConfigurationInfo info = am.getDeviceConfigurationInfo(); // NOTE: We assume all ICS devices have OpenGL ES 2.0. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // below 4.0, check OpenGL ES 2.0 support. - ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); - ConfigurationInfo info = am.getDeviceConfigurationInfo(); if (info.reqGlEsVersion < 0x20000) { - throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device"); + throw new UnsupportedOperationException("OpenGL ES 2.0 or better is not supported on this device"); } } else if (Build.VERSION.SDK_INT < 9){ throw new UnsupportedOperationException("jME3 requires Android 2.3 or later"); @@ -126,7 +127,8 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex // setEGLContextClientVersion must be set before calling setRenderer // this means it cannot be set in AndroidConfigChooser (too late) - view.setEGLContextClientVersion(2); + // use proper openGL ES version + view.setEGLContextClientVersion(info.reqGlEsVersion>>16); view.setFocusableInTouchMode(true); view.setFocusable(true); @@ -201,7 +203,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex gl = new GLDebugES((GL) gl, (GLExt) gl, (GLFbo) gl); } if (settings.getBoolean("GraphicsTrace")) { - gl = GLTracer.createGlesTracer(gl, GL.class, GLFbo.class, GLExt.class); + gl = GLTracer.createGlesTracer(gl, GL.class, GLES_30.class, GLFbo.class, GLExt.class); } renderer = new GLRenderer((GL)gl, (GLExt)gl, (GLFbo)gl); renderer.initialize(); diff --git a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java index bf6b41b7a..0c92e19e9 100644 --- a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java +++ b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java @@ -41,6 +41,7 @@ import com.jme3.renderer.Caps; import com.jme3.scene.Spatial; import com.jme3.shader.Glsl100ShaderGenerator; import com.jme3.shader.Glsl150ShaderGenerator; +import com.jme3.shader.Glsl300ShaderGenerator; import com.jme3.shader.ShaderGenerator; import com.jme3.system.JmeSystem; import com.jme3.texture.Texture; @@ -434,7 +435,9 @@ public class DesktopAssetManager implements AssetManager { @Override public ShaderGenerator getShaderGenerator(EnumSet caps) { if (shaderGenerator == null) { - if(caps.contains(Caps.GLSL150)){ + if(caps.contains(Caps.OpenGLES30) && caps.contains(Caps.GLSL300)){ + shaderGenerator = new Glsl300ShaderGenerator(this); + }else if(caps.contains(Caps.GLSL150)) { shaderGenerator = new Glsl150ShaderGenerator(this); }else{ shaderGenerator = new Glsl100ShaderGenerator(this); 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 d4094f015..5dea0c5ec 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Caps.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Caps.java @@ -403,7 +403,45 @@ public enum Caps { /** * Supporting working with ShaderStorageBufferObjects. */ - ShaderStorageBufferObject; + ShaderStorageBufferObject, + + /** + * Supports OpenGL ES 3.0 + */ + OpenGLES30, + + /** + * Supports GLSL 3.0 + */ + GLSL300, + + /** + * Supports OpenGL ES 3.1 + */ + OpenGLES31, + + /** + * Supports GLSL 3.1 + */ + GLSL310, + + /** + * Supports OpenGL ES 3.2 + */ + OpenGLES32, + + /** + * Supports GLSL 3.2 + */ + GLSL320, + + /** + * Explicit support of depth 24 textures + */ + Depth24; + + + /** * Returns true if given the renderer capabilities, the texture diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLDebugES.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLDebugES.java index 8746d57ed..19546f20f 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLDebugES.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLDebugES.java @@ -5,7 +5,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; -public class GLDebugES extends GLDebug implements GL, GLFbo, GLExt { +public class GLDebugES extends GLDebug implements GL, GL2, GLES_30, GLFbo, GLExt { private final GLFbo glfbo; private final GLExt glext; @@ -609,4 +609,54 @@ public class GLDebugES extends GLDebug implements GL, GLFbo, GLExt { glfbo.glFramebufferTextureLayerEXT(param1, param2, param3, param4, param5); checkError(); } + + public void glAlphaFunc(int func, float ref) { + ((GL2)gl).glAlphaFunc(func, ref); + checkError(); + } + + public void glPointSize(float size) { + ((GL2)gl).glPointSize(size); + checkError(); + } + + public void glPolygonMode(int face, int mode) { + ((GL2)gl).glPolygonMode(face, mode); + checkError(); + } + + public void glDrawBuffer(int mode) { + ((GL2)gl).glDrawBuffer(mode); + checkError(); + } + + public void glReadBuffer(int mode) { + ((GL2)gl).glReadBuffer(mode); + checkError(); + } + + public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, + int border, ByteBuffer data) { + ((GL2)gl).glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, data); + checkError(); + } + + public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, + int height, int depth, int format, ByteBuffer data) { + ((GL2)gl).glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, data); + checkError(); + } + + public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, + int format, int type, ByteBuffer data) { + ((GL2)gl).glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data); + checkError(); + } + + public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, + int depth, int format, int type, ByteBuffer data) { + ((GL2)gl).glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data); + checkError(); + } + } diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLES_30.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLES_30.java new file mode 100644 index 000000000..017dae816 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLES_30.java @@ -0,0 +1,46 @@ +/* + * 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 com.jme3.renderer.opengl; + +import java.nio.ByteBuffer; + +/** + * GL functions and constants only available on vanilla OpenGL ES 3.0. + * + * @author Jesus Oliver + */ +public interface GLES_30 extends GL { + + public static final int GL_RGB10_A2 = 0x8059; + public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368; + +} 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 52c9a5b3d..6daee5aff 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 @@ -166,7 +166,7 @@ public final class GLImageFormats { format(formatToGL, Format.Luminance8, GLExt.GL_RGBA8, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); format(formatToGL, Format.Luminance8Alpha8, GLExt.GL_RGBA8, GL.GL_LUMINANCE_ALPHA, GL.GL_UNSIGNED_BYTE); } - format(formatToGL, Format.RGB8, GLExt.GL_RGBA8, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.RGB8, GL2.GL_RGB8, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); format(formatToGL, Format.RGBA8, GLExt.GL_RGBA8, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); formatSwiz(formatToGL, Format.BGR8, GL2.GL_RGB8, GL2.GL_RGB, GL.GL_UNSIGNED_BYTE); @@ -217,8 +217,28 @@ public final class GLImageFormats { format(formatToGL, Format.RGB16F_to_RGB9E5, GLExt.GL_RGB9_E5_EXT, GL.GL_RGB, halfFloatFormat); } } + + // Supported in GLES30 core + if (caps.contains(Caps.OpenGLES30)) { + format(formatToGL, Format.RGB10A2, GLES_30.GL_RGB10_A2, GL.GL_RGBA, GLES_30.GL_UNSIGNED_INT_2_10_10_10_REV); + format(formatToGL, Format.Alpha8, GL2.GL_ALPHA8, GL.GL_ALPHA, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.Luminance8, GL.GL_LUMINANCE, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); + format(formatToGL, Format.Luminance8Alpha8, GL.GL_LUMINANCE_ALPHA, GL.GL_LUMINANCE_ALPHA, GL.GL_UNSIGNED_BYTE); + + formatSrgb(formatToGL, Format.RGB8, GLExt.GL_SRGB8_EXT, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); + formatSrgb(formatToGL, Format.RGBA8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); + + //Depending on the device could be better to use the previously defined extension based float textures instead of gles3.0 texture formats +// if (!caps.contains(Caps.FloatTexture)) { + format(formatToGL, Format.RGB16F, GLExt.GL_RGB16F_ARB, GL.GL_RGB, GLExt.GL_HALF_FLOAT_ARB); + format(formatToGL, Format.RGB32F, GLExt.GL_RGB32F_ARB, GL.GL_RGB, GL.GL_FLOAT); + format(formatToGL, Format.RGBA16F, GLExt.GL_RGBA16F_ARB, GL.GL_RGBA, GLExt.GL_HALF_FLOAT_ARB); + format(formatToGL, Format.RGBA32F, GLExt.GL_RGBA32F_ARB, GL.GL_RGBA, GL.GL_FLOAT); +// } + format(formatToGL, Format.RGB111110F, GLExt.GL_R11F_G11F_B10F_EXT, GL.GL_RGB, GLExt.GL_UNSIGNED_INT_10F_11F_11F_REV_EXT); + } - // Need to check if Caps.DepthTexture is supported prior to using for textures + // Need to check if Caps.DepthTexture is supported prior to using for textures // But for renderbuffers its OK. format(formatToGL, Format.Depth16, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_SHORT); @@ -228,7 +248,7 @@ public final class GLImageFormats { } else { format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); } - if (caps.contains(Caps.OpenGL20)) { + if (caps.contains(Caps.OpenGL20) || caps.contains(Caps.Depth24)) { format(formatToGL, Format.Depth24, GL2.GL_DEPTH_COMPONENT24, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT); } if (caps.contains(Caps.FloatDepthBuffer)) { 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 0e5a01d99..0d9e60d14 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 @@ -71,6 +71,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; + public final class GLRenderer implements Renderer { private static final Logger logger = Logger.getLogger(GLRenderer.class.getName()); @@ -166,9 +167,28 @@ public final class GLRenderer implements Renderer { } private void loadCapabilitiesES() { + int oglVer = extractVersion(gl.glGetString(GL.GL_VERSION)); caps.add(Caps.GLSL100); caps.add(Caps.OpenGLES20); + caps.add(Caps.Multisample); + + if (oglVer >= 300) { + caps.add(Caps.OpenGLES30); + caps.add(Caps.GLSL300); + // Instancing is core in GLES300 + caps.add(Caps.MeshInstancing); + } + if (oglVer >= 310) { + caps.add(Caps.OpenGLES31); + caps.add(Caps.GLSL310); + } + if (oglVer >= 320) { + caps.add(Caps.OpenGLES32); + caps.add(Caps.GLSL320); + caps.add(Caps.GeometryShader); + caps.add(Caps.TesselationShader); + } // Important: Do not add OpenGL20 - that's the desktop capability! } @@ -293,6 +313,7 @@ public final class GLRenderer implements Renderer { if (hasExtension("GL_ARB_draw_instanced") && hasExtension("GL_ARB_instanced_arrays")) { + // TODO: If there were a way to call the EXT extension for GLES2, should check also (hasExtension("GL_EXT_draw_instanced") && hasExtension("GL_EXT_instanced_arrays")) caps.add(Caps.MeshInstancing); } @@ -330,8 +351,10 @@ public final class GLRenderer implements Renderer { if (hasExtension("GL_OES_depth_texture") || gl2 != null) { caps.add(Caps.DepthTexture); + } - // TODO: GL_OES_depth24 + if (hasExtension("GL_OES_depth24")) { + caps.add(Caps.Depth24); } if (hasExtension("GL_OES_rgb8_rgba8") || @@ -340,7 +363,7 @@ public final class GLRenderer implements Renderer { caps.add(Caps.Rgba8); } - if (caps.contains(Caps.OpenGL30) || hasExtension("GL_OES_packed_depth_stencil")) { + if (caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30) || hasExtension("GL_OES_packed_depth_stencil")) { caps.add(Caps.PackedDepthStencilBuffer); } @@ -350,7 +373,7 @@ public final class GLRenderer implements Renderer { caps.add(Caps.FloatColorBuffer); } - if (hasExtension("GL_ARB_depth_buffer_float")) { + if (caps.contains(Caps.OpenGLES30) || hasExtension("GL_ARB_depth_buffer_float")) { caps.add(Caps.FloatDepthBuffer); } @@ -397,7 +420,7 @@ public final class GLRenderer implements Renderer { caps.add(Caps.PartialNonPowerOfTwoTextures); } - if (hasExtension("GL_EXT_texture_array") || caps.contains(Caps.OpenGL30)) { + if (hasExtension("GL_EXT_texture_array") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { caps.add(Caps.TextureArray); } @@ -414,16 +437,16 @@ public final class GLRenderer implements Renderer { limits.put(Limits.RenderBufferSize, getInteger(GLFbo.GL_MAX_RENDERBUFFER_SIZE_EXT)); limits.put(Limits.FrameBufferAttachments, getInteger(GLFbo.GL_MAX_COLOR_ATTACHMENTS_EXT)); - if (hasExtension("GL_EXT_framebuffer_blit") || caps.contains(Caps.OpenGL30)) { + if (hasExtension("GL_EXT_framebuffer_blit") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { caps.add(Caps.FrameBufferBlit); } - if (hasExtension("GL_EXT_framebuffer_multisample")) { + if (hasExtension("GL_EXT_framebuffer_multisample") || caps.contains(Caps.OpenGLES30)) { caps.add(Caps.FrameBufferMultisample); limits.put(Limits.FrameBufferSamples, getInteger(GLExt.GL_MAX_SAMPLES_EXT)); } - if (hasExtension("GL_ARB_texture_multisample")) { + if (hasExtension("GL_ARB_texture_multisample") || caps.contains(Caps.OpenGLES31)) { // GLES31 does not fully support it caps.add(Caps.TextureMultisample); limits.put(Limits.ColorTextureSamples, getInteger(GLExt.GL_MAX_COLOR_TEXTURE_SAMPLES)); limits.put(Limits.DepthTextureSamples, getInteger(GLExt.GL_MAX_DEPTH_TEXTURE_SAMPLES)); @@ -432,8 +455,8 @@ public final class GLRenderer implements Renderer { limits.put(Limits.FrameBufferSamples, limits.get(Limits.ColorTextureSamples)); } } - - if (hasExtension("GL_ARB_draw_buffers") || caps.contains(Caps.OpenGL30)) { + + if (hasExtension("GL_ARB_draw_buffers") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { limits.put(Limits.FrameBufferMrtAttachments, getInteger(GLExt.GL_MAX_DRAW_BUFFERS_ARB)); if (limits.get(Limits.FrameBufferMrtAttachments) > 1) { caps.add(Caps.FrameBufferMRT); @@ -443,7 +466,7 @@ public final class GLRenderer implements Renderer { } } - if (hasExtension("GL_ARB_multisample")) { + if (hasExtension("GL_ARB_multisample") /*|| caps.contains(Caps.OpenGLES20)*/) { boolean available = getInteger(GLExt.GL_SAMPLE_BUFFERS_ARB) != 0; int samples = getInteger(GLExt.GL_SAMPLES_ARB); logger.log(Level.FINER, "Samples: {0}", samples); @@ -498,6 +521,14 @@ public final class GLRenderer implements Renderer { limits.put(Limits.UniformBufferObjectMaxVertexBlocks, getInteger(GL3.GL_MAX_VERTEX_UNIFORM_BLOCKS)); } + if (hasExtension("GL_OES_geometry_shader") || hasExtension("GL_EXT_geometry_shader")) { + caps.add(Caps.GeometryShader); + } + + if (hasExtension("GL_OES_tessellation_shader") || hasExtension("GL_EXT_tessellation_shader")) { + caps.add(Caps.TesselationShader); + } + // Print context information logger.log(Level.INFO, "OpenGL Renderer Information\n" + " * Vendor: {0}\n" + @@ -539,7 +570,7 @@ public final class GLRenderer implements Renderer { } private void loadCapabilities() { - if (gl2 != null) { + if (gl2 != null && !(gl instanceof GLES_30)) { loadCapabilitiesGL2(); } else { loadCapabilitiesES(); @@ -1327,10 +1358,11 @@ public final class GLRenderer implements Renderer { throw new RendererException("Cannot recompile shader source"); } + boolean gles3 = caps.contains(Caps.OpenGLES30); boolean gles2 = caps.contains(Caps.OpenGLES20); String language = source.getLanguage(); - if (gles2 && !language.equals("GLSL100")) { + if (!gles3 && gles2 && !language.equals("GLSL100")) { //avoid this check for gles3 throw new RendererException("This shader cannot run in OpenGL ES 2. " + "Only GLSL 1.00 shaders are supported."); } @@ -1339,24 +1371,25 @@ public final class GLRenderer implements Renderer { // Upload shader source. // Merge the defines and source code. stringBuf.setLength(0); + int version = Integer.parseInt(language.substring(4)); if (language.startsWith("GLSL")) { - int version = Integer.parseInt(language.substring(4)); if (version > 100) { stringBuf.append("#version "); stringBuf.append(language.substring(4)); if (version >= 150) { - stringBuf.append(" core"); + if(gles3) { + stringBuf.append(" es"); + } + else { + stringBuf.append(" core"); + } } stringBuf.append("\n"); } else { - if (gles2) { + if (gles2 || gles3) { // request GLSL ES (1.00) when compiling under GLES2. stringBuf.append("#version 100\n"); - if (source.getType() == ShaderType.Fragment) { - // GLES2 requires precision qualifier. - insertPrecision = true; - } } else { // version 100 does not exist in desktop GLSL. // put version 110 in that case to enable strict checking @@ -1364,6 +1397,15 @@ public final class GLRenderer implements Renderer { stringBuf.append("#version 110\n"); } } + + if (gles2 || gles3) { + //Inserting precision only to fragment shaders creates some link failures because of different precision between shaders + //But adding the precision to all shaders generates rendering glitches in some devices if not set to highp + if (source.getType() == ShaderType.Fragment) { + // GLES requires precision qualifier. + insertPrecision = true; + } + } } if (linearizeSrgbImages) { @@ -1375,11 +1417,22 @@ public final class GLRenderer implements Renderer { stringBuf.append(source.getSource()); if(insertPrecision){ + // default precision could be defined in GLSLCompat.glsllib so final users can use custom defined precision instead // precision token is not a preprocessor dirrective therefore it must be placed after #extension tokens to avoid // Error P0001: Extension directive must occur before any non-preprocessor tokens int idx = stringBuf.lastIndexOf("#extension"); idx = stringBuf.indexOf("\n", idx); - stringBuf.insert(idx + 1, "precision mediump float;\n"); + + if(version>=310) { + stringBuf.insert(idx + 1, "precision highp sampler2DMS;\n"); + } + if(version>=300) { + stringBuf.insert(idx + 1, "precision highp sampler2DArray;\n"); + stringBuf.insert(idx + 1, "precision highp sampler2DShadow;\n"); + stringBuf.insert(idx + 1, "precision highp sampler3D;\n"); + stringBuf.insert(idx + 1, "precision highp sampler2D;\n"); + } + stringBuf.insert(idx + 1, "precision highp float;\n"); } intBuf1.clear(); @@ -1612,6 +1665,7 @@ public final class GLRenderer implements Renderer { if (copyDepth) { mask |= GL.GL_DEPTH_BUFFER_BIT; } + glfbo.glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, GL.GL_NEAREST); @@ -1842,7 +1896,7 @@ public final class GLRenderer implements Renderer { } public void setReadDrawBuffers(FrameBuffer fb) { - if (gl2 == null) { + if (gl2 == null || gl instanceof GLES_30) { return; } @@ -1982,6 +2036,7 @@ public final class GLRenderer implements Renderer { context.boundReadBuf = rb.getSlot(); } } + } else { setFrameBuffer(null); } @@ -2048,7 +2103,7 @@ public final class GLRenderer implements Renderer { return GLExt.GL_TEXTURE_2D_ARRAY_EXT; } case ThreeDimensional: - if (!caps.contains(Caps.OpenGL20)) { + if (!caps.contains(Caps.OpenGL20) && !caps.contains(Caps.OpenGLES30)) { throw new RendererException("3D textures are not supported" + " by the video hardware."); } @@ -2172,9 +2227,9 @@ public final class GLRenderer implements Renderer { switch (tex.getType()) { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords - if (gl2 != null && curState.rWrap != tex.getWrap(WrapAxis.R)) { + if (gl2 != null && (caps.contains(Caps.OpenGL20) || caps.contains(Caps.OpenGLES30)) && curState.rWrap != tex.getWrap(WrapAxis.R)) { bindTextureAndUnit(target, image, unit); - gl2.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); + gl.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); curState.rWrap = tex.getWrap(WrapAxis.R); } //There is no break statement on purpose here @@ -2196,17 +2251,17 @@ public final class GLRenderer implements Renderer { } ShadowCompareMode texCompareMode = tex.getShadowCompareMode(); - if (gl2 != null && curState.shadowCompareMode != texCompareMode) { + if ( (gl2 != null || caps.contains(Caps.OpenGLES30)) && curState.shadowCompareMode != texCompareMode) { bindTextureAndUnit(target, image, unit); if (texCompareMode != ShadowCompareMode.Off) { - gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE); + gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE); if (texCompareMode == ShadowCompareMode.GreaterOrEqual) { - gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL); + gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL); } else { - gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL); + gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL); } } else { - gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE); + gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE); } curState.shadowCompareMode = texCompareMode; } @@ -2340,7 +2395,6 @@ public final class GLRenderer implements Renderer { bindTextureAndUnit(target, img, unit); int imageSamples = img.getMultiSamples(); - if (imageSamples <= 1) { if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) { // Image does not have mipmaps, but they are required. @@ -2353,7 +2407,7 @@ public final class GLRenderer implements Renderer { // For OpenGL3 and up. // We'll generate mipmaps via glGenerateMipmapEXT (see below) } - } else if (caps.contains(Caps.OpenGL20)) { + } else if (caps.contains(Caps.OpenGL20) || caps.contains(Caps.OpenGLES30)) { if (img.hasMipmaps()) { // Image already has mipmaps, set the max level based on the // number of mipmaps we have. @@ -3136,6 +3190,7 @@ public final class GLRenderer implements Renderer { public boolean isTaskResultAvailable(int taskId) { return gl.glGetQueryObjectiv(taskId, GL.GL_QUERY_RESULT_AVAILABLE) == 1; } + @Override public boolean getAlphaToCoverage() { if (caps.contains(Caps.Multisample)) { 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 db5331e11..8c0d407b9 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 @@ -142,13 +142,13 @@ final class TextureUtil { 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 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 000000000..450a21a5f --- /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/texture/Image.java b/jme3-core/src/main/java/com/jme3/texture/Image.java index eaa3aae8a..f7cee1b55 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 class Image extends NativeObject implements Savable /*, Cloneable*/ { * 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 bbad96ace..993ce508b 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 @@ abstract class ImageCodec { 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 e40992696..977007f07 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 824a17369..4a5fa256e 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 077b08579..4eaa6a88f 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 8465d2f0b..40b4f9a6c 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 f765d2044..4c609dca8 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 148c88f1c..529dea4ba 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 9d40ec523..29932c7c5 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 fd8ea8a24..ce588b60a 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 0023b0b81..05188796c 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 c1ace91d1..697db195d 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 4ecd33157..8dc1e2a72 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 c7c6b8851..eb3380ce1 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-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md index 68f329892..2debc760c 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 613955536..590dbdc05 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 6cf780e1f..0f5b5433e 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 ef6b278ec..aaa7bd8ac 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 f5a1892ca..2314876d6 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 13582e148..529b8327b 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 c52a8d692..d97e23dcb 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 b75bd2c45..49c5a06e5 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/texture/TestTexture3D.java b/jme3-examples/src/main/java/jme3test/texture/TestTexture3D.java index a7e553a9a..1e151bf74 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 @@ public class TestTexture3D extends SimpleApplication { 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 391e4efcc..1757c021b 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 class TestTextureArray extends SimpleApplication 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 2187c58d8..738f4b94c 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 class TestTextureArrayCompressed extends SimpleApplication } - 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 class TestTextureArrayCompressed extends SimpleApplication 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 355cf6092..4b888e81d 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 6a3219e60..bcbee23d8 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 9d1153c3d..3f85e3063 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 55862acf9..2e811ad03 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 1ba260594..61b35c99a 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 f91b7b309..4681a3625 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 e70bc5b25..9664f996a 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 a42bd381e..ee00681d3 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 6d27bc030..2514cb532 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-testdata/src/main/resources/Materials/Geom/SimpleGeom.frag b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.frag index 636af0c7e..ac75aaf04 100644 --- a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.frag +++ b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.frag @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + void main(){ gl_FragColor=vec4(1.0,0.0,1.0,0.5); -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom index e0c5d7b9e..7acd056e8 100644 --- a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom +++ b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom @@ -7,8 +7,8 @@ const float PI = 3.1415926; void main(){ for (int i = 0; i <= 10; i++) { - float ang = PI * 2.0 / 10.0 * i; - vec4 offset = vec4(cos(ang) * 5, -sin(ang) * 5, 0.0, 0.0); + float ang = PI * 2.0 / 10.0 * float(i); + vec4 offset = vec4(cos(ang) * 5.0, -sin(ang) * 5.0, 0.0, 0.0); gl_Position = g_WorldViewProjectionMatrix*vec4(gl_in[0].gl_Position.xyz + offset.xyz,1.0); EmitVertex(); diff --git a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.j3md b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.j3md index 4ae79e3ed..b2289b30d 100644 --- a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.j3md +++ b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.j3md @@ -5,13 +5,13 @@ MaterialDef SimpleGeom { } Technique { - VertexShader GLSL330: Materials/Geom/SimpleGeom.vert - GeometryShader GLSL330: Materials/Geom/SimpleGeom.geom - FragmentShader GLSL330: Materials/Geom/SimpleGeom.frag + VertexShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.vert + GeometryShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.geom + FragmentShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.frag WorldParameters { WorldViewProjectionMatrix } } -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.vert b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.vert index f82ebb79b..1653607cd 100644 --- a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.vert +++ b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.vert @@ -1,5 +1,7 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + attribute vec3 inPosition; void main(){ gl_Position=vec4(inPosition,1); -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.frag b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.frag index 636af0c7e..ac75aaf04 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.frag +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.frag @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + void main(){ gl_FragColor=vec4(1.0,0.0,1.0,0.5); -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.j3md b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.j3md index 81813493d..5797bea53 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.j3md +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.j3md @@ -6,14 +6,14 @@ MaterialDef SimpleGeom { } Technique { - VertexShader GLSL400: Materials/Tess/SimpleTess.vert - TessellationEvaluationShader GLSL400: Materials/Tess/SimpleTess.tseval - TessellationControlShader GLSL400: Materials/Tess/SimpleTess.tsctrl - FragmentShader GLSL400: Materials/Tess/SimpleTess.frag + VertexShader GLSL400 GLSL320: Materials/Tess/SimpleTess.vert + TessellationEvaluationShader GLSL400 GLSL320: Materials/Tess/SimpleTess.tseval + TessellationControlShader GLSL400 GLSL320: Materials/Tess/SimpleTess.tsctrl + FragmentShader GLSL400 GLSL320: Materials/Tess/SimpleTess.frag WorldParameters { WorldViewProjectionMatrix } } -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl index 3f7074642..81b4e291a 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl @@ -5,13 +5,15 @@ out gl_PerVertex{ uniform int m_TessellationFactor; void main(){ if (gl_InvocationID == 0){ - gl_TessLevelOuter[0]=m_TessellationFactor; - gl_TessLevelOuter[1]=m_TessellationFactor; - gl_TessLevelOuter[2]=m_TessellationFactor; - gl_TessLevelOuter[3]=m_TessellationFactor; + float f_TessellationFactor=float(m_TessellationFactor); - gl_TessLevelInner[0]=m_TessellationFactor; - gl_TessLevelInner[1]=m_TessellationFactor; + gl_TessLevelOuter[0]=f_TessellationFactor; + gl_TessLevelOuter[1]=f_TessellationFactor; + gl_TessLevelOuter[2]=f_TessellationFactor; + gl_TessLevelOuter[3]=f_TessellationFactor; + + gl_TessLevelInner[0]=f_TessellationFactor; + gl_TessLevelInner[1]=f_TessellationFactor; } gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval index 445276e42..4dbf976f3 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval @@ -8,6 +8,6 @@ void main(){ vec3 p1 = mix(gl_in[1].gl_Position.xyz, gl_in[2].gl_Position.xyz, gl_TessCoord.x); // interpolate in vert direction vec3 tePosition = mix(p0, p1, gl_TessCoord.y); - gl_Position = g_WorldViewProjectionMatrix * vec4(tePosition, 1); + gl_Position = g_WorldViewProjectionMatrix * vec4(tePosition, 1.0); } diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.vert b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.vert index f82ebb79b..1653607cd 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.vert +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.vert @@ -1,5 +1,7 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + attribute vec3 inPosition; void main(){ gl_Position=vec4(inPosition,1); -} \ No newline at end of file +} diff --git a/jme3-testdata/src/main/resources/Scenes/Beach/FullskiesSunset0068.dds b/jme3-testdata/src/main/resources/Scenes/Beach/FullskiesSunset0068.dds index 6d5e0d8e8..44b0b41ba 100644 Binary files a/jme3-testdata/src/main/resources/Scenes/Beach/FullskiesSunset0068.dds and b/jme3-testdata/src/main/resources/Scenes/Beach/FullskiesSunset0068.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/3D/flame.dds b/jme3-testdata/src/main/resources/Textures/3D/flame.dds index 2eb00f746..0a19ac0e8 100644 Binary files a/jme3-testdata/src/main/resources/Textures/3D/flame.dds and b/jme3-testdata/src/main/resources/Textures/3D/flame.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Sky/Bright/BrightSky.dds b/jme3-testdata/src/main/resources/Textures/Sky/Bright/BrightSky.dds index 3379320ab..1da88cf5f 100644 Binary files a/jme3-testdata/src/main/resources/Textures/Sky/Bright/BrightSky.dds and b/jme3-testdata/src/main/resources/Textures/Sky/Bright/BrightSky.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Sky/Bright/FullskiesBlueClear03.dds b/jme3-testdata/src/main/resources/Textures/Sky/Bright/FullskiesBlueClear03.dds index 1a86a1fda..a79cbe75c 100644 Binary files a/jme3-testdata/src/main/resources/Textures/Sky/Bright/FullskiesBlueClear03.dds and b/jme3-testdata/src/main/resources/Textures/Sky/Bright/FullskiesBlueClear03.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall.dds b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall.dds index 7efe7899c..2ac3b8b86 100644 Binary files a/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall.dds and b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_dxt5.dds b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_dxt5.dds new file mode 100644 index 000000000..7efe7899c Binary files /dev/null and b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_dxt5.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_normal_parallax.dds b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_normal_parallax.dds index fd93003dd..df93b19cc 100644 Binary files a/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_normal_parallax.dds and b/jme3-testdata/src/main/resources/Textures/Terrain/BrickWall/BrickWall_normal_parallax.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond.dds b/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond.dds index 309f2c7d4..7470ead5d 100644 Binary files a/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond.dds and b/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond.dds differ diff --git a/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond_dxt5.dds b/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond_dxt5.dds new file mode 100644 index 000000000..309f2c7d4 Binary files /dev/null and b/jme3-testdata/src/main/resources/Textures/Terrain/Pond/Pond_dxt5.dds differ diff --git a/lib/android.jar b/lib/android.jar index b94c81518..66e18e077 100644 Binary files a/lib/android.jar and b/lib/android.jar differ