From 4e851bfeeb82baab9ec3102d91ecbb292ec6ee0e Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Sat, 2 Sep 2023 15:28:26 +0200 Subject: [PATCH] GL ES 3.0 megapatch (#2061) * Extend GL ES 3.0 support. Enable CoreProfile capability when using GL ES 3.0. Add WebGL caps. * Fix contrast adjustment matdef * Improve GL ->GLES compatibility: Detect if RGB float attachment is supported, implement correct glDrawBuffer shim, add explicit GLES 300 support in all materials * Allow setReadDrawBuffers in GLES 30+, add DepthTexture capability in GLES 30+ * Make passing boundDrawBufferId to shaders toggleable (default true). Disable in tests * Revert "Allow setReadDrawBuffers in GLES 30+, add DepthTexture capability in GLES 30+" This reverts commit d8c7e96d2937bcaa68527cb1b8171a2e11124d35. * Fix tests * Set default precision in GLSLCompat only if supported * Set highp for samplerCube and int. Do not check for GL_FRAGMENT_PRECISION_HIGH as it is not always declared despite the specs. * Fix GLES formats declaration --- .../com/jme3/renderer/android/AndroidGL.java | 32 ++++++- .../com/jme3/post/FilterPostProcessor.java | 8 +- .../main/java/com/jme3/post/HDRRenderer.java | 6 +- .../src/main/java/com/jme3/renderer/Caps.java | 16 ++++ .../java/com/jme3/renderer/RenderManager.java | 40 +++++++- .../main/java/com/jme3/renderer/Renderer.java | 6 ++ .../com/jme3/renderer/opengl/GLES_30.java | 7 ++ .../jme3/renderer/opengl/GLImageFormats.java | 2 +- .../com/jme3/renderer/opengl/GLRenderer.java | 90 ++++++++++-------- .../java/com/jme3/system/NullRenderer.java | 5 + .../main/java/com/jme3/system/Platform.java | 14 ++- .../Common/MatDefs/Blur/HGaussianBlur.j3md | 9 +- .../Common/MatDefs/Blur/RadialBlur.j3md | 6 +- .../Common/MatDefs/Blur/VGaussianBlur.j3md | 9 +- .../resources/Common/MatDefs/Gui/Gui.j3md | 19 +--- .../resources/Common/MatDefs/Hdr/LogLum.j3md | 6 +- .../resources/Common/MatDefs/Hdr/ToneMap.j3md | 6 +- .../Common/MatDefs/Light/Deferred.j3md | 6 +- .../Common/MatDefs/Light/Deferred.vert | 2 + .../resources/Common/MatDefs/Light/GBuf.vert | 2 + .../Common/MatDefs/Light/Lighting.j3md | 33 ++++--- .../Common/MatDefs/Light/PBRLighting.j3md | 28 +++--- .../Common/MatDefs/Misc/ColoredTextured.j3md | 12 ++- .../Common/MatDefs/Misc/ColoredTextured.vert | 2 + .../Common/MatDefs/Misc/Particle.j3md | 21 ++-- .../Common/MatDefs/Misc/ShowNormals.j3md | 6 +- .../resources/Common/MatDefs/Misc/Sky.j3md | 6 +- .../Common/MatDefs/Misc/SkyNonCube.j3md | 6 +- .../Common/MatDefs/Misc/Unshaded.j3md | 26 +++-- .../MatDefs/Shadow/BasicPostShadow.j3md | 6 +- .../Common/MatDefs/Shadow/PostShadow.j3md | 6 +- .../MatDefs/Shadow/PostShadowFilter.j3md | 11 ++- .../Common/MatDefs/Shadow/PreShadow.j3md | 12 ++- .../Common/ShaderLib/GLSLCompat.glsllib | 36 ++++++- .../jme3/material/MaterialMatParamTest.java | 2 +- .../java/com/jme3/material/MaterialTest.java | 2 +- .../test/java/com/jme3/system/TestUtil.java | 12 ++- .../Common/MatDefs/Post/BloomExtract.j3md | 6 +- .../Common/MatDefs/Post/BloomFinal.j3md | 8 +- .../Common/MatDefs/Post/CartoonEdge.j3md | 6 +- .../Common/MatDefs/Post/Compose.j3md | 6 +- .../MatDefs/Post/ContrastAdjustment.frag | 6 +- .../MatDefs/Post/ContrastAdjustment.j3md | 16 ++-- .../MatDefs/Post/ContrastAdjustment15.frag | 95 ------------------- .../Common/MatDefs/Post/CrossHatch.j3md | 9 +- .../Common/MatDefs/Post/DepthOfField.j3md | 6 +- .../resources/Common/MatDefs/Post/FXAA.j3md | 9 +- .../resources/Common/MatDefs/Post/Fade.j3md | 6 +- .../resources/Common/MatDefs/Post/Fog.j3md | 6 +- .../Common/MatDefs/Post/LightScattering.j3md | 6 +- .../Common/MatDefs/Post/Overlay.j3md | 6 +- .../resources/Common/MatDefs/Post/Post15.vert | 2 + .../Common/MatDefs/Post/Posterization.j3md | 8 +- .../Common/MatDefs/Post/ToneMap.j3md | 6 +- .../resources/Common/MatDefs/SSAO/ssao.j3md | 4 +- .../Common/MatDefs/SSAO/ssaoBlur.j3md | 4 +- .../Common/MatDefs/Water/SimpleWater.j3md | 9 +- .../resources/Common/MatDefs/Water/Water.j3md | 4 +- .../java/com/jme3/renderer/ios/IosGL.java | 15 +++ .../Common/MatDefs/Nifty/NiftyQuad.j3md | 4 +- .../Common/MatDefs/Nifty/NiftyQuadGrad.j3md | 4 +- .../Common/MatDefs/Nifty/NiftyTex.j3md | 4 +- .../MatDefs/Terrain/AdvancedPBRTerrain.j3md | 16 ++-- .../MatDefs/Terrain/HeightBasedTerrain.j3md | 9 +- .../Common/MatDefs/Terrain/PBRTerrain.j3md | 16 ++-- .../Common/MatDefs/Terrain/Terrain.j3md | 6 +- .../MatDefs/Terrain/TerrainLighting.j3md | 26 +++-- .../resources/Materials/Geom/SimpleGeom.geom | 2 + .../Materials/Tess/SimpleTess.tsctrl | 2 + .../Materials/Tess/SimpleTess.tseval | 2 + .../Common/MatDefs/VR/CartoonSSAO.j3md | 11 ++- .../Common/MatDefs/VR/GuiOverlay.j3md | 11 ++- .../resources/Common/MatDefs/VR/OpenVR.j3md | 15 +-- .../Common/MatDefs/VR/PostShadowFilter.j3md | 11 ++- .../resources/Common/MatDefs/VR/Unshaded.j3md | 11 ++- 75 files changed, 568 insertions(+), 343 deletions(-) delete mode 100644 jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment15.frag 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 c9b4dac5e2..4c2601e1d4 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 @@ -45,6 +45,7 @@ public class AndroidGL implements GL, GL2, GLES_30, GLExt, GLFbo { IntBuffer tmpBuff = BufferUtils.createIntBuffer(1); + IntBuffer tmpBuff16 = BufferUtils.createIntBuffer(16); @Override public void resetStats() { @@ -694,10 +695,17 @@ public void glPolygonMode(int face, int mode) { // Wrapper to DrawBuffers as there's no DrawBuffer method in GLES @Override public void glDrawBuffer(int mode) { - tmpBuff.clear(); - tmpBuff.put(0, mode); - tmpBuff.rewind(); - glDrawBuffers(tmpBuff); + int nBuffers = (mode - GLFbo.GL_COLOR_ATTACHMENT0_EXT) + 1; + if (nBuffers <= 0 || nBuffers > 16) { + throw new IllegalArgumentException("Draw buffer outside range: " + Integer.toHexString(mode)); + } + tmpBuff16.clear(); + for (int i = 0; i < nBuffers - 1; i++) { + tmpBuff16.put(GL.GL_NONE); + } + tmpBuff16.put(mode); + tmpBuff16.flip(); + glDrawBuffers(tmpBuff16); } @Override @@ -729,5 +737,21 @@ public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int GLES30.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data); } + @Override + public void glBindVertexArray(int array) { + GLES30.glBindVertexArray(array); + } + + @Override + public void glDeleteVertexArrays(IntBuffer arrays) { + GLES30.glDeleteVertexArrays(arrays.limit(),arrays); + } + + @Override + public void glGenVertexArrays(IntBuffer arrays) { + GLES30.glGenVertexArrays(arrays.limit(),arrays); + + } + } diff --git a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java index f7b6d185df..5b881b5116 100644 --- a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java +++ b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java @@ -149,10 +149,12 @@ public void initialize(RenderManager rm, ViewPort vp) { fsQuad.setHeight(1); if (!renderer.getCaps().contains(Caps.PackedFloatTexture)) { - if (!renderer.getCaps().contains(Caps.FloatTexture)) { - fbFormat = Format.RGB8; - } else { + if(renderer.getCaps().contains(Caps.FloatColorBufferRGB)){ fbFormat = Format.RGB16F; + } else if(renderer.getCaps().contains(Caps.FloatColorBufferRGBA)){ + fbFormat = Format.RGBA16F; + } else { + fbFormat = Format.RGB8; } } diff --git a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java index 241401ff15..2e31413d24 100644 --- a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java +++ b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java @@ -91,7 +91,7 @@ public class HDRRenderer implements SceneProcessor { private float whiteLevel = 100f; private float throttle = -1; private int maxIterations = -1; - private Image.Format bufFormat = Format.RGB16F; + private Image.Format bufFormat = Format.RGB8; private MinFilter fbMinFilter = MinFilter.BilinearNoMipMaps; private MagFilter fbMagFilter = MagFilter.Bilinear; @@ -106,8 +106,10 @@ public HDRRenderer(AssetManager manager, Renderer renderer) { Collection caps = renderer.getCaps(); if (caps.contains(Caps.PackedFloatColorBuffer)) bufFormat = Format.RGB111110F; - else if (caps.contains(Caps.FloatColorBuffer)) + else if (caps.contains(Caps.FloatColorBufferRGB)) bufFormat = Format.RGB16F; + else if (caps.contains(Caps.FloatColorBufferRGBA)) + bufFormat = Format.RGBA16F; else { enabled = false; return; 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 961d78ae6f..647d44a9a6 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Caps.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Caps.java @@ -227,6 +227,16 @@ public enum Caps { */ FloatTexture, + /** + * Supports rendering on RGB floating point textures + */ + FloatColorBufferRGB, + + /** + * Supports rendering on RGBA floating point textures + */ + FloatColorBufferRGBA, + /** * Supports integer textures. */ @@ -236,6 +246,7 @@ public enum Caps { * Supports floating point FBO color buffers (Format.RGB16F). */ FloatColorBuffer, + /** * Supports floating point depth buffer. @@ -341,6 +352,11 @@ public enum Caps { */ OpenGLES20, + /** + * Supports WebGL + */ + WebGL, + /** * Supports RGB8 / RGBA8 textures. */ diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java index a1b453a096..5969a1d5bd 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java @@ -58,8 +58,10 @@ import com.jme3.shader.Shader; import com.jme3.shader.UniformBinding; import com.jme3.shader.UniformBindingManager; +import com.jme3.shader.VarType; import com.jme3.system.NullRenderer; import com.jme3.system.Timer; +import com.jme3.texture.FrameBuffer; import com.jme3.util.SafeArrayList; import java.util.ArrayList; import java.util.Collections; @@ -101,6 +103,7 @@ public class RenderManager { private LightFilter lightFilter = new DefaultLightFilter(); private TechniqueDef.LightMode preferredLightMode = TechniqueDef.LightMode.MultiPass; private int singlePassLightBatchSize = 1; + private MatParamOverride boundDrawBufferId=new MatParamOverride(VarType.Int,"BoundDrawBuffer",0); /** @@ -111,6 +114,7 @@ public class RenderManager { */ public RenderManager(Renderer renderer) { this.renderer = renderer; + this.forcedOverrides.add(boundDrawBufferId); } /** @@ -629,6 +633,12 @@ public void renderGeometry(Geometry geom) { setWorldMatrix(geom.getWorldMatrix()); } + // Use material override to pass the current target index (used in api such as GL ES that do not support glDrawBuffer) + FrameBuffer currentFb = this.renderer.getCurrentFrameBuffer(); + if (currentFb != null && !currentFb.isMultiTarget()) { + this.boundDrawBufferId.setValue(currentFb.getTargetIndex()); + } + // Perform light filtering if we have a light filter. LightList lightList = geom.getWorldLightList(); @@ -639,7 +649,7 @@ public void renderGeometry(Geometry geom) { } Material material = geom.getMaterial(); - + // If forcedTechnique exists, we try to force it for the render. // If it does not exist in the mat def, we check for forcedMaterial and render the geom if not null. // Otherwise, the geometry is not rendered. @@ -1298,4 +1308,32 @@ public void render(float tpf, boolean mainFrameBufferActive) { } } } + + + /** + * Returns true if the draw buffer target id is passed to the shader. + * + * @return True if the draw buffer target id is passed to the shaders. + */ + public boolean getPassDrawBufferTargetIdToShaders() { + return this.forcedOverrides.contains(boundDrawBufferId); + } + + /** + * Enable or disable passing the draw buffer target id to the shaders. This + * is needed to handle FrameBuffer.setTargetIndex correctly in some + * backends. + * + * @param v + * True to enable, false to disable (default is true) + */ + public void setPassDrawBufferTargetIdToShaders(boolean v) { + if (v) { + if (!this.forcedOverrides.contains(boundDrawBufferId)) { + this.forcedOverrides.add(boundDrawBufferId); + } + } else { + this.forcedOverrides.remove(boundDrawBufferId); + } + } } diff --git a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java index 753bf2f1a6..63e49f030b 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java @@ -527,4 +527,10 @@ public default void pushDebugGroup(String name) { } + /** + * Returns the current FrameBuffer that is being rendered to. + * @return the FrameBuffer or null if rendering to the screen. + */ + public FrameBuffer getCurrentFrameBuffer(); + } 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 index 42c59d940b..755e076cac 100644 --- 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 @@ -31,6 +31,8 @@ */ package com.jme3.renderer.opengl; +import java.nio.IntBuffer; + /** * GL functions and constants only available on vanilla OpenGL ES 3.0. * @@ -40,5 +42,10 @@ 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; + + public void glBindVertexArray(int array); + public void glDeleteVertexArrays(IntBuffer arrays); + + public void glGenVertexArrays(IntBuffer arrays); } 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 2532f5837e..396af9ee34 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 @@ -121,7 +121,7 @@ public static GLImageFormat[][] getFormatsForCaps(EnumSet caps) { formatSrgbSwiz(formatToGL, Format.Luminance8Alpha8, GLExt.GL_SRGB8_ALPHA8_EXT, GL3.GL_RG, GL.GL_UNSIGNED_BYTE); } - if (caps.contains(Caps.OpenGL20)) { + if (caps.contains(Caps.OpenGL20)||caps.contains(Caps.OpenGLES30)) { if (!caps.contains(Caps.CoreProfile)) { format(formatToGL, Format.Alpha8, GL2.GL_ALPHA8, GL.GL_ALPHA, GL.GL_UNSIGNED_BYTE); format(formatToGL, Format.Luminance8, GL2.GL_LUMINANCE8, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); 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 dfe62113f8..59bc8e3838 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 @@ -187,7 +187,12 @@ private HashSet loadExtensions() { return extensionSet; } + public static boolean isWebGL(String version) { + return version.contains("WebGL"); + } + public static int extractVersion(String version) { + if (version.startsWith("WebGL 2.0")) return 300; Matcher m = GLVERSION_PATTERN.matcher(version); if (m.matches()) { int major = Integer.parseInt(m.group(1)); @@ -208,7 +213,11 @@ private boolean hasExtension(String extensionName) { } private void loadCapabilitiesES() { - int oglVer = extractVersion(gl.glGetString(GL.GL_VERSION)); + String version = gl.glGetString(GL.GL_VERSION); + int oglVer = extractVersion(version); + if (isWebGL(version)) { + caps.add(Caps.WebGL); + } caps.add(Caps.GLSL100); caps.add(Caps.OpenGLES20); @@ -378,7 +387,7 @@ private void loadCapabilitiesCommon() { hasExtension("GL_ARB_half_float_pixel"); if (!hasFloatTexture) { - hasFloatTexture = caps.contains(Caps.OpenGL30); + hasFloatTexture = caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30); } } @@ -409,9 +418,14 @@ private void loadCapabilitiesCommon() { } if (hasExtension("GL_ARB_color_buffer_float") && - hasExtension("GL_ARB_half_float_pixel")) { + hasExtension("GL_ARB_half_float_pixel") + ||caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { // XXX: Require both 16- and 32-bit float support for FloatColorBuffer. caps.add(Caps.FloatColorBuffer); + caps.add(Caps.FloatColorBufferRGBA); + if (!caps.contains(Caps.OpenGLES30)) { + caps.add(Caps.FloatColorBufferRGB); + } } if (caps.contains(Caps.OpenGLES30) || hasExtension("GL_ARB_depth_buffer_float")) { @@ -450,13 +464,13 @@ private void loadCapabilitiesCommon() { // == end texture format extensions == - if (hasExtension("GL_ARB_vertex_array_object") || caps.contains(Caps.OpenGL30)) { + if (hasExtension("GL_ARB_vertex_array_object") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30) ) { caps.add(Caps.VertexBufferArray); } if (hasExtension("GL_ARB_texture_non_power_of_two") || hasExtension("GL_OES_texture_npot") || - caps.contains(Caps.OpenGL30)) { + caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { caps.add(Caps.NonPowerOfTwoTextures); } else { logger.log(Level.WARNING, "Your graphics card does not " @@ -530,7 +544,7 @@ private void loadCapabilitiesCommon() { // Supports sRGB pipeline. if ( (hasExtension("GL_ARB_framebuffer_sRGB") && hasExtension("GL_EXT_texture_sRGB")) - || caps.contains(Caps.OpenGL30)) { + || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) { caps.add(Caps.Srgb); } @@ -539,8 +553,10 @@ private void loadCapabilitiesCommon() { caps.add(Caps.SeamlessCubemap); } - if (caps.contains(Caps.OpenGL32) && !hasExtension("GL_ARB_compatibility")) { - caps.add(Caps.CoreProfile); + if ((caps.contains(Caps.OpenGLES30) || caps.contains(Caps.OpenGL32)) && !hasExtension("GL_ARB_compatibility")) { + if (JmeSystem.getPlatform().getOs() != Platform.Os.iOS) { // some features are not supported on iOS + caps.add(Caps.CoreProfile); + } } if (hasExtension("GL_ARB_get_program_binary")) { @@ -679,9 +695,17 @@ public void initialize() { if (caps.contains(Caps.CoreProfile)) { // Core Profile requires VAO to be bound. - gl3.glGenVertexArrays(intBuf16); - int vaoId = intBuf16.get(0); - gl3.glBindVertexArray(vaoId); + if(gl3!=null){ + gl3.glGenVertexArrays(intBuf16); + int vaoId = intBuf16.get(0); + gl3.glBindVertexArray(vaoId); + }else if(gl instanceof GLES_30){ + ((GLES_30)gl).glGenVertexArrays(intBuf16); + int vaoId = intBuf16.get(0); + ((GLES_30)gl).glBindVertexArray(vaoId); + } else{ + throw new UnsupportedOperationException("Core profile not supported"); + } } if (gl2 != null && !(gl instanceof GLES_30)) { gl2.glEnable(GL2.GL_VERTEX_PROGRAM_POINT_SIZE); @@ -1521,7 +1545,6 @@ public void updateShaderSourceData(ShaderSource source) { + "Only GLSL 1.00 shaders are supported."); } - boolean insertPrecision = false; // Upload shader source. // Merge the defines and source code. stringBuf.setLength(0); @@ -1552,16 +1575,8 @@ public void updateShaderSourceData(ShaderSource source) { } } - 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) { stringBuf.append("#define SRGB 1\n"); } @@ -1570,24 +1585,6 @@ public void updateShaderSourceData(ShaderSource source) { stringBuf.append(source.getDefines()); 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 directive 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); - - 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(); intBuf1.put(0, stringBuf.length()); @@ -1712,7 +1709,7 @@ public void updateShaderData(Shader shader) { public void setShader(Shader shader) { if (shader == null) { throw new IllegalArgumentException("Shader cannot be null"); - } else { + } else { if (shader.isUpdateNeeded()) { updateShaderData(shader); } @@ -2073,8 +2070,17 @@ public void setMainFrameBufferOverride(FrameBuffer fb) { mainFbOverride = fb; } + + @Override + public FrameBuffer getCurrentFrameBuffer() { + if(mainFbOverride!=null){ + return mainFbOverride; + } + return context.boundFB; + } + public void setReadDrawBuffers(FrameBuffer fb) { - if (gl2 == null || gl instanceof GLES_30) { + if (gl2 == null) { return; } @@ -2679,7 +2685,7 @@ public void setTexture(int unit, Texture tex) throws TextureUnitException { if (unit < 0 || unit >= RenderContext.maxTextureUnits) { throw new TextureUnitException(); } - + Image image = tex.getImage(); if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) { // Check NPOT requirements diff --git a/jme3-core/src/main/java/com/jme3/system/NullRenderer.java b/jme3-core/src/main/java/com/jme3/system/NullRenderer.java index e82dea5149..4975b69a17 100644 --- a/jme3-core/src/main/java/com/jme3/system/NullRenderer.java +++ b/jme3-core/src/main/java/com/jme3/system/NullRenderer.java @@ -293,4 +293,9 @@ public boolean isLinearizeSrgbImages() { public boolean isMainFrameBufferSrgb() { return false; } + + @Override + public FrameBuffer getCurrentFrameBuffer() { + return null; + } } diff --git a/jme3-core/src/main/java/com/jme3/system/Platform.java b/jme3-core/src/main/java/com/jme3/system/Platform.java index f187d2fbdf..64595a9106 100644 --- a/jme3-core/src/main/java/com/jme3/system/Platform.java +++ b/jme3-core/src/main/java/com/jme3/system/Platform.java @@ -139,7 +139,13 @@ public enum Platform { /** * Android running on unknown platform (could be x86 or mips for example). */ - Android_Other(Os.Android); + Android_Other(Os.Android), + + /** + * Generic web platform on unknown architecture + */ + Web(Os.Web, true) // assume always 64-bit, it shouldn't matter for web + ; /** @@ -165,7 +171,11 @@ public enum Os { /** * Android operating systems */ - Android + Android, + /** + * Generic web platform + */ + Web } private final boolean is64bit; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md index 7c5fddeb6c..f7011c5f20 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md @@ -1,6 +1,7 @@ MaterialDef HGaussianBlur { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float Size @@ -8,10 +9,14 @@ MaterialDef HGaussianBlur { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Blur/HGaussianBlur.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Blur/HGaussianBlur.frag WorldParameters { } + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } } \ No newline at end of file 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 977007f073..806bb55473 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md @@ -1,6 +1,7 @@ MaterialDef Radial Blur { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Color Color @@ -10,13 +11,14 @@ MaterialDef Radial Blur { } Technique { - VertexShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Post/Post.vert - FragmentShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag + VertexShader GLSL300 GLSL150 GLSL120 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL120 : Common/MatDefs/Blur/RadialBlur.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples } } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md index 68e5d15baf..8bcb4292f2 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md @@ -1,6 +1,7 @@ MaterialDef VGaussianBlur { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float Size @@ -8,10 +9,14 @@ MaterialDef VGaussianBlur { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Blur/VGaussianBlur.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Blur/VGaussianBlur.frag WorldParameters { } + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.j3md b/jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.j3md index 23fbff8261..b3da65be47 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Gui/Gui.j3md @@ -1,37 +1,26 @@ MaterialDef Default GUI { MaterialParameters { + Int BoundDrawBuffer Texture2D Texture Color Color (Color) Boolean VertexColor (UseVertexColor) } Technique { - VertexShader GLSL150: Common/MatDefs/Gui/Gui.vert - FragmentShader GLSL150: Common/MatDefs/Gui/Gui.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Gui/Gui.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Gui/Gui.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TEXTURE : Texture VERTEX_COLOR : VertexColor } } - Technique { - VertexShader GLSL100: Common/MatDefs/Gui/Gui.vert - FragmentShader GLSL100: Common/MatDefs/Gui/Gui.frag - - WorldParameters { - WorldViewProjectionMatrix - } - - Defines { - TEXTURE : Texture - VERTEX_COLOR : VertexColor - } - } } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.j3md b/jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.j3md index 0c4c6c889e..31358d224e 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.j3md @@ -1,6 +1,7 @@ MaterialDef Log Lum 2D { MaterialParameters { + Int BoundDrawBuffer Texture2D Texture Vector2 BlockSize Vector2 PixelSize @@ -12,14 +13,15 @@ MaterialDef Log Lum 2D { } Technique { - VertexShader GLSL100: Common/MatDefs/Gui/Gui.vert - FragmentShader GLSL100: Common/MatDefs/Hdr/LogLum.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Gui/Gui.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Hdr/LogLum.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TEXTURE ENCODE_LUM : EncodeLum DECODE_LUM : DecodeLum diff --git a/jme3-core/src/main/resources/Common/MatDefs/Hdr/ToneMap.j3md b/jme3-core/src/main/resources/Common/MatDefs/Hdr/ToneMap.j3md index 24fbd04ae6..b515639eda 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Hdr/ToneMap.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Hdr/ToneMap.j3md @@ -1,5 +1,6 @@ MaterialDef Tone Mapper { MaterialParameters { + Int BoundDrawBuffer Texture2D Texture Texture2D Lum Texture2D Lum2 @@ -9,14 +10,15 @@ MaterialDef Tone Mapper { Float Gamma } Technique { - VertexShader GLSL100: Common/MatDefs/Gui/Gui.vert - FragmentShader GLSL100: Common/MatDefs/Hdr/ToneMap.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Gui/Gui.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Hdr/ToneMap.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TEXTURE } } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md index f0b7ee5a6f..08a7d007f8 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md @@ -2,6 +2,7 @@ MaterialDef Phong Lighting Deferred { MaterialParameters { + Int BoundDrawBuffer // Use more efficient algorithms to improve performance Boolean LowQuality @@ -35,8 +36,8 @@ MaterialDef Phong Lighting Deferred { Technique { LightMode MultiPass - VertexShader GLSL100: Common/MatDefs/Light/Deferred.vert - FragmentShader GLSL100: Common/MatDefs/Light/Deferred.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Deferred.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Deferred.frag WorldParameters { WorldViewProjectionMatrix @@ -46,6 +47,7 @@ MaterialDef Phong Lighting Deferred { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer ATTENUATION : Attenuation V_TANGENT : VTangent MINNAERT : Minnaert diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.vert index 0743cc1a94..1d22a36edb 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.vert @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + varying vec2 texCoord; attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/GBuf.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/GBuf.vert index f4ad199635..66eca303b0 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/GBuf.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/GBuf.vert @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + uniform mat4 g_WorldViewProjectionMatrix; uniform mat4 g_WorldMatrix; 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 4a5fa256ee..ec85c0729e 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md @@ -1,6 +1,7 @@ MaterialDef Phong Lighting { MaterialParameters { + Int BoundDrawBuffer // Compute vertex lighting in the shader // For better performance @@ -133,8 +134,8 @@ MaterialDef Phong Lighting { Technique { LightMode SinglePass - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/SPLighting.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/SPLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -146,7 +147,8 @@ MaterialDef Phong Lighting { ViewProjectionMatrix } - Defines { + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer VERTEX_COLOR : UseVertexColor VERTEX_LIGHTING : VertexLighting MATERIAL_COLORS : UseMaterialColors @@ -180,8 +182,8 @@ MaterialDef Phong Lighting { LightMode MultiPass - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100 : Common/MatDefs/Light/Lighting.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Lighting.frag WorldParameters { WorldViewProjectionMatrix @@ -194,6 +196,7 @@ MaterialDef Phong Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer VERTEX_COLOR : UseVertexColor VERTEX_LIGHTING : VertexLighting MATERIAL_COLORS : UseMaterialColors @@ -225,8 +228,8 @@ MaterialDef Phong Lighting { Technique PreShadow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -236,6 +239,7 @@ MaterialDef Phong Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DISCARD_ALPHA : AlphaDiscardThreshold NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -255,8 +259,8 @@ MaterialDef Phong Lighting { Technique PostShadow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -267,6 +271,7 @@ MaterialDef Phong Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge @@ -292,8 +297,8 @@ MaterialDef Phong Lighting { Technique PreNormalPass { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -304,6 +309,7 @@ MaterialDef Phong Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DIFFUSEMAP_ALPHA : DiffuseMap NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -315,8 +321,8 @@ MaterialDef Phong Lighting { Technique Glow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix @@ -325,6 +331,7 @@ MaterialDef Phong Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NEED_TEXCOORD1 HAS_GLOWMAP : GlowMap HAS_GLOWCOLOR : GlowColor 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 57954738a7..2b2d5453f4 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md @@ -1,6 +1,7 @@ MaterialDef PBR Lighting { MaterialParameters { + Int BoundDrawBuffer // Alpha threshold for fragment discarding Float AlphaDiscardThreshold (AlphaTestFallOff) @@ -129,8 +130,8 @@ MaterialDef PBR Lighting { Technique { LightMode SinglePassAndImageBased - VertexShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert - FragmentShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag + VertexShader GLSL300 GLSL150 GLSL110: Common/MatDefs/Light/PBRLighting.vert + FragmentShader GLSL300 GLSL150 GLSL110: Common/MatDefs/Light/PBRLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -141,7 +142,8 @@ MaterialDef PBR Lighting { ViewMatrix } - Defines { + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer BASECOLORMAP : BaseColorMap NORMALMAP : NormalMap NORMALSCALE : NormalScale @@ -176,8 +178,8 @@ MaterialDef PBR Lighting { Technique PreShadow { - VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadowPBR.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadowPBR.frag WorldParameters { WorldViewProjectionMatrix @@ -187,6 +189,7 @@ MaterialDef PBR Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DISCARD_ALPHA : AlphaDiscardThreshold NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -206,8 +209,8 @@ MaterialDef PBR Lighting { Technique PostShadow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadowPBR.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadowPBR.frag WorldParameters { WorldViewProjectionMatrix @@ -217,6 +220,7 @@ MaterialDef PBR Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge @@ -241,8 +245,8 @@ MaterialDef PBR Lighting { Technique PreNormalPass { - VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -253,6 +257,7 @@ MaterialDef PBR Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer BASECOLORMAP_ALPHA : BaseColorMap NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -264,8 +269,8 @@ MaterialDef PBR Lighting { Technique Glow { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix @@ -274,6 +279,7 @@ MaterialDef PBR Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NEED_TEXCOORD1 NUM_BONES : NumberOfBones INSTANCING : UseInstancing diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md index 497b7d0a7b..86b1d8e212 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.j3md @@ -2,20 +2,22 @@ Exception This material definition is deprecated. Please use Unshaded.j3md inste MaterialDef Colored Textured { MaterialParameters { + Int BoundDrawBuffer Texture2D ColorMap Color Color (Color) } Technique { - VertexShader GLSL100: Common/MatDefs/Misc/ColoredTextured.vert - FragmentShader GLSL100: Common/MatDefs/Misc/ColoredTextured.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/ColoredTextured.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/ColoredTextured.frag WorldParameters { WorldViewProjectionMatrix } + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } - Technique { - } - + } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.vert index 572d841917..1ff1602be4 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ColoredTextured.vert @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + uniform mat4 g_WorldViewProjectionMatrix; attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md index 504062ffaa..db49951cd7 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md @@ -1,6 +1,7 @@ MaterialDef Point Sprite { MaterialParameters { + Int BoundDrawBuffer Texture2D Texture Float Quadratic Boolean PointSprite @@ -24,8 +25,8 @@ MaterialDef Point Sprite { // Point sprite should be used if running on ES2, but crash // if on desktop (because its not supported by HW) - VertexShader GLSL100 GLSL100 GLSL150 : Common/MatDefs/Misc/Particle.vert - FragmentShader GLSL100 GLSL120 GLSL150 : Common/MatDefs/Misc/Particle.frag + VertexShader GLSL300 GLSL150 GLSL120 GLSL100: Common/MatDefs/Misc/Particle.vert + FragmentShader GLSL300 GLSL150 GLSL120 GLSL100: Common/MatDefs/Misc/Particle.frag WorldParameters { WorldViewProjectionMatrix @@ -41,6 +42,7 @@ MaterialDef Point Sprite { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer USE_TEXTURE : Texture POINT_SPRITE : PointSprite } @@ -48,8 +50,8 @@ MaterialDef Point Sprite { Technique PreShadow { - VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -59,6 +61,7 @@ MaterialDef Point Sprite { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer COLOR_MAP : Texture } @@ -74,8 +77,8 @@ MaterialDef Point Sprite { Technique SoftParticles{ - VertexShader GLSL100 GLSL150 : Common/MatDefs/Misc/SoftParticle.vert - FragmentShader GLSL120 GLSL150 : Common/MatDefs/Misc/SoftParticle.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/SoftParticle.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/SoftParticle.frag WorldParameters { WorldViewProjectionMatrix @@ -91,6 +94,7 @@ MaterialDef Point Sprite { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer USE_TEXTURE : Texture POINT_SPRITE : PointSprite RESOLVE_DEPTH_MS : NumSamplesDepth @@ -99,14 +103,15 @@ MaterialDef Point Sprite { Technique Glow { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NEED_TEXCOORD1 HAS_GLOWMAP : GlowMap HAS_GLOWCOLOR : GlowColor diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md index 8972d7d9cf..a067c49fb6 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md @@ -1,12 +1,13 @@ MaterialDef Debug Normals { MaterialParameters { + Int BoundDrawBuffer // For instancing Boolean UseInstancing } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/ShowNormals.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/ShowNormals.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/ShowNormals.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/ShowNormals.frag WorldParameters { WorldViewProjectionMatrix @@ -16,6 +17,7 @@ MaterialDef Debug Normals { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : UseInstancing } } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md index b4710db62e..e1b503472d 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md @@ -1,13 +1,14 @@ MaterialDef Sky Plane { MaterialParameters { + Int BoundDrawBuffer TextureCubeMap Texture Boolean SphereMap Boolean EquirectMap Vector3 NormalScale } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Misc/Sky.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Misc/Sky.frag WorldParameters { ViewMatrix @@ -16,6 +17,7 @@ MaterialDef Sky Plane { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer SPHERE_MAP : SphereMap EQUIRECT_MAP : EquirectMap } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/SkyNonCube.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/SkyNonCube.j3md index 15bb8c8be9..d039af39f5 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/SkyNonCube.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/SkyNonCube.j3md @@ -1,13 +1,14 @@ MaterialDef Sky Plane { MaterialParameters { + Int BoundDrawBuffer Texture2D Texture Boolean SphereMap Boolean EquirectMap Vector3 NormalScale } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Sky.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Sky.frag WorldParameters { ViewMatrix @@ -16,6 +17,7 @@ MaterialDef Sky Plane { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer SPHERE_MAP : SphereMap EQUIRECT_MAP : EquirectMap } 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 4617b4b354..b5854c2a23 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md @@ -1,6 +1,7 @@ MaterialDef Unshaded { MaterialParameters { + Int BoundDrawBuffer Texture2D ColorMap Texture2D LightMap Color Color (Color) @@ -65,8 +66,8 @@ MaterialDef Unshaded { } Technique { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100 : Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100 : Common/MatDefs/Misc/Unshaded.frag WorldParameters { WorldViewProjectionMatrix @@ -75,6 +76,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : UseInstancing SEPARATE_TEXCOORD : SeparateTexCoord HAS_COLORMAP : ColorMap @@ -92,8 +94,8 @@ MaterialDef Unshaded { Technique PreNormalPass { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -104,6 +106,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer COLORMAP_ALPHA : ColorMap NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -114,8 +117,8 @@ MaterialDef Unshaded { Technique PreShadow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -125,6 +128,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer COLOR_MAP : ColorMap DISCARD_ALPHA : AlphaDiscardThreshold NUM_BONES : NumberOfBones @@ -145,8 +149,8 @@ MaterialDef Unshaded { Technique PostShadow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -156,6 +160,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge @@ -181,8 +186,8 @@ MaterialDef Unshaded { Technique Glow { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix @@ -191,6 +196,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NEED_TEXCOORD1 HAS_GLOWMAP : GlowMap HAS_GLOWCOLOR : GlowColor diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md index 4ba3815446..71e215b62e 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md @@ -1,13 +1,14 @@ MaterialDef Basic Post Shadow { MaterialParameters { + Int BoundDrawBuffer Texture2D ShadowMap Matrix4 LightViewProjectionMatrix } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/BasicPostShadow.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/BasicPostShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/BasicPostShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/BasicPostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -15,6 +16,7 @@ MaterialDef Basic Post Shadow { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NO_SHADOW2DPROJ } 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 c3d0c51afc..6aad6d4ac8 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md @@ -1,6 +1,7 @@ MaterialDef Post Shadow { MaterialParameters { + Int BoundDrawBuffer Int FilterMode Boolean HardwareShadows @@ -35,8 +36,8 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL310 GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -44,6 +45,7 @@ MaterialDef Post Shadow { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge 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 05188796c6..e5739281f8 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md @@ -1,6 +1,7 @@ MaterialDef Post Shadow { MaterialParameters { + Int BoundDrawBuffer Int FilterMode Boolean HardwareShadows @@ -42,14 +43,15 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter.vert - FragmentShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter15.frag + VertexShader GLSL310 GLSL300 GLSL150 : Common/MatDefs/Shadow/PostShadowFilter.vert + FragmentShader GLSL310 GLSL300 GLSL150 : Common/MatDefs/Shadow/PostShadowFilter15.frag WorldParameters { ResolutionInverse } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth HARDWARE_SHADOWS : HardwareShadows @@ -65,14 +67,15 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag WorldParameters { ResolutionInverse } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md index a76b36310b..72f1097bfc 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md @@ -1,7 +1,15 @@ MaterialDef Pre Shadow { + MaterialParameters { + Int BoundDrawBuffer + } + Technique { - VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib index 1805595627..77cb34c8c0 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib @@ -1,3 +1,17 @@ +#ifdef FRAGMENT_SHADER + precision highp float; + precision highp int; + precision highp sampler2DArray; + precision highp sampler2DShadow; + precision highp samplerCube; + precision highp sampler3D; + precision highp sampler2D; + #if __VERSION__ >= 310 + precision highp sampler2DMS; + #endif + +#endif + #if defined GL_ES # define hfloat highp float # define hvec2 highp vec2 @@ -19,11 +33,25 @@ #endif #if __VERSION__ >= 130 -# ifdef GL_ES -out highp vec4 outFragColor; -# else -out vec4 outFragColor; + +#ifdef FRAGMENT_SHADER + #ifdef GL_ES + #ifdef BOUND_DRAW_BUFFER + #for i=0..15 ( #if $i<=BOUND_DRAW_BUFFER $0 #endif ) + #if BOUND_DRAW_BUFFER == $i + layout( location = $i ) out highp vec4 outFragColor; + #else + layout( location = $i ) out highp vec4 outNOP$i; + #endif + #endfor + #else + out highp vec4 outFragColor; + #endif + #else + out vec4 outFragColor; + #endif #endif + # define texture1D texture # define texture2D texture # define texture3D texture diff --git a/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java b/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java index fc4503b1aa..9b572e8e93 100644 --- a/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java +++ b/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java @@ -449,7 +449,7 @@ public void setTexture(int unit, Texture texture) { MaterialMatParamTest.this.usedTextures[unit] = texture; } }; - private final RenderManager renderManager = new RenderManager(renderer); + private final RenderManager renderManager = TestUtil.createRenderManager(renderer); private boolean evaluated = false; private Shader usedShader = null; diff --git a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java index e48b33b2dd..6edd3ed34a 100644 --- a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java +++ b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java @@ -104,7 +104,7 @@ public void testSelectDefaultTechnique_GLSL120Cap_MultipleLangs() { material.selectTechnique("Default", renderManager); - checkRequiredCaps(Caps.GLSL100, Caps.GLSL120); + checkRequiredCaps(Caps.GLSL120); } @Test diff --git a/jme3-core/src/test/java/com/jme3/system/TestUtil.java b/jme3-core/src/test/java/com/jme3/system/TestUtil.java index ba6b833252..b23d1846ee 100644 --- a/jme3-core/src/test/java/com/jme3/system/TestUtil.java +++ b/jme3-core/src/test/java/com/jme3/system/TestUtil.java @@ -35,6 +35,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.renderer.RenderManager; +import com.jme3.renderer.Renderer; + import java.util.logging.Level; import java.util.logging.Logger; @@ -55,7 +57,13 @@ public static AssetManager createAssetManager() { return new DesktopAssetManager(true); } - public static RenderManager createRenderManager() { - return new RenderManager(new NullRenderer()); + public static RenderManager createRenderManager() { + return createRenderManager(new NullRenderer()); + } + + public static RenderManager createRenderManager(Renderer renderer) { + RenderManager rm = new RenderManager(renderer); + rm.setPassDrawBufferTargetIdToShaders(false); + return rm; } } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomExtract.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomExtract.j3md index d3e51dd573..4171380e6d 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomExtract.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomExtract.j3md @@ -1,6 +1,7 @@ MaterialDef Bloom { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float ExposurePow @@ -10,13 +11,14 @@ MaterialDef Bloom { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/bloomExtract.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/bloomExtract.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HAS_GLOWMAP : GlowMap DO_EXTRACT : Extract RESOLVE_MS : NumSamples diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomFinal.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomFinal.j3md index 817764cab9..e356e1f07f 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomFinal.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/BloomFinal.j3md @@ -1,20 +1,22 @@ MaterialDef Bloom Final { MaterialParameters { - Int NumSamples + Int BoundDrawBuffer + Int NumSamples Texture2D Texture Texture2D BloomTex Float BloomIntensity } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/bloomFinal.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/bloomFinal.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples } } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/CartoonEdge.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/CartoonEdge.j3md index c7a740bcc0..59001feec2 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/CartoonEdge.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/CartoonEdge.j3md @@ -1,6 +1,7 @@ MaterialDef Cartoon Edge { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -16,8 +17,8 @@ MaterialDef Cartoon Edge { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/CartoonEdge.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/CartoonEdge.frag WorldParameters { WorldViewMatrix @@ -25,6 +26,7 @@ MaterialDef Cartoon Edge { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Compose.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/Compose.j3md index 8f5e584df0..b24909cdb8 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Compose.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Compose.j3md @@ -1,6 +1,7 @@ MaterialDef Default GUI { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -8,13 +9,14 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/Compose.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Compose.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.frag index f3e499d64c..363d078a1b 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.frag @@ -37,9 +37,11 @@ * Then a power law is applied, using the exponent for each channel. * Finally, the output value is scaled linearly, using the scaling factor for each channel. * - * Supports GLSL100 GLSL110 GLSL120 GLSL130. */ +#import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/MultiSample.glsllib" + //constant inputs from java source uniform float m_redChannelExponent; uniform float m_greenChannelExponent; @@ -55,7 +57,7 @@ uniform float m_lowerLimit; uniform float m_upperLimit; //container for the input from post.vert -uniform sampler2D m_Texture; +uniform COLORTEXTURE m_Texture; //varying input from post.vert vertex shader varying vec2 texCoord; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.j3md index 83c0e1125f..7c2ee7bea7 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment.j3md @@ -4,6 +4,7 @@ MaterialDef ColorAdjustmentFilter { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float redChannelExponent @@ -15,14 +16,17 @@ MaterialDef ColorAdjustmentFilter { Float greenChannelScale Float blueChannelScale } + Technique { - VertexShader GLSL150 GLSL300 GLSL310 GLSL320: Common/MatDefs/Post/Post15.vert - FragmentShader GLSL150 GLSL300 GLSL310 GLSL320: Common/MatDefs/Post/ContrastAdjustment15.frag - } + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/ContrastAdjustment.frag + WorldParameters { + } - Technique { - VertexShader GLSL100 GLSL110 GLSL120 GLSL130: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100 GLSL110 GLSL120 GLSL130: Common/MatDefs/Post/ContrastAdjustment.frag + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + NUM_SAMPLES : NumSamples + } } } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment15.frag deleted file mode 100644 index c92bbc9901..0000000000 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ContrastAdjustment15.frag +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2009-2021 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. - */ - -/* - * Used by ContrastAdjustment.j3md to adjust the color channels. - * - * First, the input range is normalized to upper and lower limits. - * Then a power law is applied, using the exponent for each channel. - * Finally, the output value is scaled linearly, using the scaling factor for each channel. - * - * Supports glsl150 and glsl150+ including android GLES glsl300, glsl310 and glsl320. - */ - -#import "Common/ShaderLib/GLSLCompat.glsllib" -#import "Common/ShaderLib/MultiSample.glsllib" - -//constant inputs from java source -uniform float m_redChannelExponent; -uniform float m_greenChannelExponent; -uniform float m_blueChannelExponent; - -//final scale values -uniform float m_redChannelScale; -uniform float m_greenChannelScale; -uniform float m_blueChannelScale; - -//input range -uniform float m_lowerLimit; -uniform float m_upperLimit; - -//container for the input from post15.vert -uniform COLORTEXTURE m_Texture; - -//varying input from post15.vert vertex shader -in vec2 texCoord; - -//the output color -out vec4 fragColor; - -void main() { - //get the color from a 2d sampler. - vec4 color = texture2D(m_Texture, texCoord); - - //apply the color transfer function. - - //1) adjust the channels input range - color.rgb = (color.rgb - vec3(m_lowerLimit)) / (vec3(m_upperLimit) - vec3(m_lowerLimit)); - - // avoid negative levels - color.r = max(color.r, 0.0); - color.g = max(color.g, 0.0); - color.b = max(color.b, 0.0); - - //2) apply transfer functions on different channels. - color.r = pow(color.r, m_redChannelExponent); - color.g = pow(color.g, m_greenChannelExponent); - color.b = pow(color.b, m_blueChannelExponent); - - //3) scale the output levels - color.r = color.r * m_redChannelScale; - color.b = color.b * m_blueChannelScale; - color.g = color.g * m_greenChannelScale; - - //4) process the textures colors. - fragColor = color; -} \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch.j3md index e5c168a630..3526dd3a3a 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch.j3md @@ -1,6 +1,7 @@ MaterialDef CrossHatch { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture; Vector4 LineColor; @@ -18,11 +19,15 @@ MaterialDef CrossHatch { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/CrossHatch.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/CrossHatch.frag WorldParameters { } + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField.j3md index 908889951b..8a7d2f354b 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField.j3md @@ -1,6 +1,7 @@ MaterialDef Depth Of Field { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -14,14 +15,15 @@ MaterialDef Depth Of Field { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/DepthOfField.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/DepthOfField.frag WorldParameters { FrustumNearFar } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth BLUR_THRESHOLD : BlurThreshold 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 2debc760c7..385a3a1666 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md @@ -1,5 +1,6 @@ MaterialDef FXAA { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float SubPixelShift @@ -8,10 +9,14 @@ MaterialDef FXAA { Float ReduceMul } Technique { - VertexShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert - FragmentShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/FXAA.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/FXAA.frag WorldParameters { ResolutionInverse } + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade.j3md index e9a55ab8b2..cac57cf21f 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade.j3md @@ -1,19 +1,21 @@ MaterialDef Fade { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture Float Value } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/Fade.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Fade.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples } } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog.j3md index b1d28103ce..b6267326a0 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog.j3md @@ -1,6 +1,7 @@ MaterialDef Fade { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -11,13 +12,14 @@ MaterialDef Fade { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/Fog.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Fog.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth } 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 590dbdc051..d7929bd022 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/LightScattering.j3md @@ -1,5 +1,6 @@ MaterialDef Light Scattering { - MaterialParameters { + MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -14,13 +15,14 @@ MaterialDef Light Scattering { } Technique { - VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert + VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/LightScattering.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth DISPLAY: Display diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay.j3md index 6cdb458883..51eb543573 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay.j3md @@ -1,6 +1,7 @@ MaterialDef Default GUI { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -8,13 +9,14 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/Overlay.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Overlay.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Post15.vert b/jme3-effects/src/main/resources/Common/MatDefs/Post/Post15.vert index 3bcd2ede01..975780ea29 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Post15.vert +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Post15.vert @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + in vec4 inPosition; in vec2 inTexCoord; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization.j3md index 635dc0f536..71ca681a48 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization.j3md @@ -1,6 +1,7 @@ MaterialDef Posterization { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture; @@ -10,14 +11,15 @@ MaterialDef Posterization { } Technique { - VertexShader GLSL150 GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL150 GLSL100: Common/MatDefs/Post/Posterization.frag + VertexShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Post/Posterization.frag WorldParameters { } Defines { - RESOLVE_MS : NumSamples + BOUND_DRAW_BUFFER: BoundDrawBuffer + RESOLVE_MS : NumSamples } } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md index 7c1eb6673d..2ca259838f 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md @@ -1,6 +1,7 @@ MaterialDef Default GUI { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -8,13 +9,14 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Post/ToneMap.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/ToneMap.frag WorldParameters { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NUM_SAMPLES : NumSamples } } 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 0f5b5433e7..f61dd1a32e 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssao.j3md @@ -1,6 +1,7 @@ MaterialDef SSAO { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -18,7 +19,7 @@ MaterialDef SSAO { } Technique { - VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert + VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/SSAO/ssao.frag WorldParameters { @@ -28,6 +29,7 @@ MaterialDef SSAO { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth APPROXIMATE_NORMALS : ApproximateNormals 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 2314876d6d..773d34c363 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur.j3md @@ -1,6 +1,7 @@ MaterialDef SSAOBlur { - MaterialParameters { + MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D Texture @@ -22,6 +23,7 @@ MaterialDef SSAOBlur { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer USE_AO : UseAo USE_ONLY_AO : UseOnlyAo RESOLVE_MS : NumSamples diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md index 7ef8775b3a..710dcd5151 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md @@ -1,6 +1,7 @@ MaterialDef Simple Water { MaterialParameters { + Int BoundDrawBuffer Texture2D water_reflection Texture2D water_refraction Texture2D water_depthmap @@ -18,8 +19,8 @@ MaterialDef Simple Water { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Water/simple_water.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Water/simple_water.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Water/simple_water.vert + FragmentShader GLSL300 GLSL150 GLSL100 : Common/MatDefs/Water/simple_water.frag WorldParameters { WorldViewProjectionMatrix @@ -27,5 +28,9 @@ MaterialDef Simple Water { Resolution CameraPosition } + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } + } } \ 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 49c5a06e53..f75e263aba 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/Water.j3md @@ -1,6 +1,7 @@ MaterialDef Advanced Water { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D FoamMap @@ -59,7 +60,8 @@ MaterialDef Advanced Water { } Defines { - RESOLVE_MS : NumSamples + BOUND_DRAW_BUFFER: BoundDrawBuffer + RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth ENABLE_RIPPLES : UseRipples ENABLE_HQ_SHORELINE : UseHQShoreline diff --git a/jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java b/jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java index dcef2a64a6..7a46d6ee9d 100644 --- a/jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java +++ b/jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java @@ -789,5 +789,20 @@ public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int JmeIosGLES.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data); } + @Override + public void glBindVertexArray(int array) { + throw new UnsupportedOperationException("Unimplemented method 'glBindVertexArray'"); + } + + @Override + public void glDeleteVertexArrays(IntBuffer arrays) { + throw new UnsupportedOperationException("Unimplemented method 'glDeleteVertexArrays'"); + } + + @Override + public void glGenVertexArrays(IntBuffer arrays) { + throw new UnsupportedOperationException("Unimplemented method 'glGenVertexArrays'"); + } + } diff --git a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuad.j3md b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuad.j3md index 73c71ac47d..ad4b26a294 100644 --- a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuad.j3md +++ b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuad.j3md @@ -5,8 +5,8 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyQuad.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyQuad.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyQuad.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyQuad.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuadGrad.j3md b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuadGrad.j3md index ca351d8ea7..fb9b19fd97 100644 --- a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuadGrad.j3md +++ b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyQuadGrad.j3md @@ -4,8 +4,8 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyQuadGrad.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyQuadGrad.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyQuadGrad.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyQuadGrad.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyTex.j3md b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyTex.j3md index e1d26494b8..12f83cf652 100644 --- a/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyTex.j3md +++ b/jme3-niftygui/src/main/resources/Common/MatDefs/Nifty/NiftyTex.j3md @@ -6,8 +6,8 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyTex.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Nifty/NiftyTex.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyTex.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Nifty/NiftyTex.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AdvancedPBRTerrain.j3md b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AdvancedPBRTerrain.j3md index 192c175165..fe0680482b 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AdvancedPBRTerrain.j3md +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AdvancedPBRTerrain.j3md @@ -2,6 +2,7 @@ MaterialDef Advanced PBR Terrain { MaterialParameters { + Int BoundDrawBuffer Boolean UseVertexColorsAsSunIntensity //set true to make the vertex color's R channel how exposed a vertex is to the sun @@ -255,8 +256,8 @@ MaterialDef Advanced PBR Terrain { LightMode SinglePassAndImageBased - VertexShader GLSL150: Common/MatDefs/Terrain/PBRTerrain.vert - FragmentShader GLSL150: Common/MatDefs/Terrain/AdvancedPBRTerrain.frag + VertexShader GLSL300 GLSL150 : Common/MatDefs/Terrain/PBRTerrain.vert + FragmentShader GLSL300 GLSL150 : Common/MatDefs/Terrain/AdvancedPBRTerrain.frag WorldParameters { WorldViewProjectionMatrix @@ -270,6 +271,7 @@ MaterialDef Advanced PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer AFFLICTIONTEXTURE : AfflictionAlphaMap AFFLICTIONALBEDOMAP: SplatAlbedoMap @@ -340,8 +342,8 @@ MaterialDef Advanced PBR Terrain { Technique PreShadow { - VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -351,6 +353,7 @@ MaterialDef Advanced PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DISCARD_ALPHA : AlphaDiscardThreshold NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -368,8 +371,8 @@ MaterialDef Advanced PBR Terrain { Technique PostShadow{ - VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -379,6 +382,7 @@ MaterialDef Advanced PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/HeightBasedTerrain.j3md b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/HeightBasedTerrain.j3md index e8ec3589b3..d2bfa0c01d 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/HeightBasedTerrain.j3md +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/HeightBasedTerrain.j3md @@ -11,6 +11,7 @@ MaterialDef Terrain { // slopeTileFactor: the texture scale for slopes // terrainSize: the total size of the terrain (used for scaling the texture) MaterialParameters { + Int BoundDrawBuffer Texture2D region1ColorMap Texture2D region2ColorMap Texture2D region3ColorMap @@ -25,14 +26,18 @@ MaterialDef Terrain { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Terrain/HeightBasedTerrain.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Terrain/HeightBasedTerrain.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/HeightBasedTerrain.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/HeightBasedTerrain.frag WorldParameters { WorldViewProjectionMatrix WorldMatrix NormalMatrix } + + Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } Technique { diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/PBRTerrain.j3md b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/PBRTerrain.j3md index 67796e5846..572bf8ef49 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/PBRTerrain.j3md +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/PBRTerrain.j3md @@ -2,6 +2,7 @@ MaterialDef PBR Terrain { MaterialParameters { + Int BoundDrawBuffer Boolean UseVertexColorsAsSunIntensity //set true to make the vertex color's R channel how exposed a vertex is to the sun @@ -228,8 +229,8 @@ MaterialDef PBR Terrain { LightMode SinglePassAndImageBased - VertexShader GLSL100 GLSL130 GLSL150: Common/MatDefs/Terrain/PBRTerrain.vert - FragmentShader GLSL100 GLSL130 GLSL150: Common/MatDefs/Terrain/PBRTerrain.frag + VertexShader GLSL300 GLSL150 GLSL130 GLSL100: Common/MatDefs/Terrain/PBRTerrain.vert + FragmentShader GLSL300 GLSL150 GLSL130 GLSL100: Common/MatDefs/Terrain/PBRTerrain.frag WorldParameters { WorldViewProjectionMatrix @@ -243,6 +244,7 @@ MaterialDef PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TILELOCATION : TileLocation AFFLICTIONTEXTURE : AfflictionAlphaMap @@ -318,8 +320,8 @@ MaterialDef PBR Terrain { Technique PreShadow { - VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -329,6 +331,7 @@ MaterialDef PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DISCARD_ALPHA : AlphaDiscardThreshold NUM_BONES : NumberOfBones INSTANCING : UseInstancing @@ -346,8 +349,8 @@ MaterialDef PBR Terrain { Technique PostShadow{ - VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -357,6 +360,7 @@ MaterialDef PBR Terrain { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/Terrain.j3md b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/Terrain.j3md index 98fe3eb9e7..1ac3b21dc1 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/Terrain.j3md +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/Terrain.j3md @@ -1,6 +1,7 @@ MaterialDef Terrain { MaterialParameters { + Int BoundDrawBuffer // use tri-planar mapping Boolean useTriPlanarMapping @@ -15,14 +16,15 @@ MaterialDef Terrain { } Technique { - VertexShader GLSL100 GLSL150: Common/MatDefs/Terrain/Terrain.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Terrain/Terrain.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/Terrain.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/Terrain.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TRI_PLANAR_MAPPING : useTriPlanarMapping } } diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.j3md b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.j3md index 353ff4e627..341ef1c683 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.j3md +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/TerrainLighting.j3md @@ -2,6 +2,7 @@ MaterialDef Terrain Lighting { MaterialParameters { + Int BoundDrawBuffer // use tri-planar mapping Boolean useTriPlanarMapping @@ -108,8 +109,8 @@ MaterialDef Terrain Lighting { LightMode MultiPass - VertexShader GLSL100 GLSL150: Common/MatDefs/Terrain/TerrainLighting.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Terrain/TerrainLighting.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/TerrainLighting.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/TerrainLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -119,6 +120,7 @@ MaterialDef Terrain Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TRI_PLANAR_MAPPING : useTriPlanarMapping TERRAIN_GRID : isTerrainGrid WARDISO : WardIso @@ -173,8 +175,8 @@ MaterialDef Terrain Lighting { LightMode SinglePass - VertexShader GLSL100 GLSL150: Common/MatDefs/Terrain/SPTerrainLighting.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Terrain/SPTerrainLighting.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/SPTerrainLighting.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Terrain/SPTerrainLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -184,6 +186,7 @@ MaterialDef Terrain Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer TRI_PLANAR_MAPPING : useTriPlanarMapping TERRAIN_GRID : isTerrainGrid WARDISO : WardIso @@ -236,8 +239,8 @@ MaterialDef Terrain Lighting { Technique PreShadow { - VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -245,6 +248,7 @@ MaterialDef Terrain Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DIFFUSEMAP_ALPHA : DiffuseMap } @@ -260,8 +264,8 @@ MaterialDef Terrain Lighting { Technique PreNormalPass { - VertexShader GLSL100 GLSL150: Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/SSAO/normal.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -270,6 +274,7 @@ MaterialDef Terrain Lighting { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer DIFFUSEMAP_ALPHA : DiffuseMap } @@ -283,14 +288,15 @@ MaterialDef Terrain Lighting { Technique Glow { - VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HAS_GLOWMAP : GlowMap HAS_GLOWCOLOR : GlowColor } diff --git a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom index 7acd056e8f..46d34e809f 100644 --- a/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom +++ b/jme3-testdata/src/main/resources/Materials/Geom/SimpleGeom.geom @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + layout (points) in; layout (line_strip) out; layout (max_vertices = 11) out; diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl index 81b4e291a5..2732b59f1f 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tsctrl @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + layout(vertices=4) out; out gl_PerVertex{ vec4 gl_Position; diff --git a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval index 4dbf976f31..1bc159a663 100644 --- a/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval +++ b/jme3-testdata/src/main/resources/Materials/Tess/SimpleTess.tseval @@ -1,3 +1,5 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" + layout (quads,equal_spacing,cw) in; uniform mat4 g_WorldViewProjectionMatrix; diff --git a/jme3-vr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md b/jme3-vr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md index 5faaf9260b..7772941ce5 100644 --- a/jme3-vr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md +++ b/jme3-vr/src/main/resources/Common/MatDefs/VR/CartoonSSAO.j3md @@ -1,6 +1,7 @@ MaterialDef CartoonSSAO { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Int NumSamplesDepth Texture2D DepthTexture @@ -14,8 +15,8 @@ MaterialDef CartoonSSAO { } Technique { - VertexShader GLSL150: Common/MatDefs/Post/Post15.vert - FragmentShader GLSL150: Common/MatDefs/VR/CartoonSSAO.frag + VertexShader GLSL300 GLSL150: Common/MatDefs/Post/Post15.vert + FragmentShader GLSL300 GLSL150: Common/MatDefs/VR/CartoonSSAO.frag WorldParameters { WorldViewProjectionMatrix @@ -24,14 +25,15 @@ MaterialDef CartoonSSAO { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NO_OUTLINE : disableOutline INSTANCING : useInstancing } } Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: Common/MatDefs/VR/CartoonSSAO.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Post/Post.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/CartoonSSAO.frag WorldParameters { WorldViewProjectionMatrix @@ -40,6 +42,7 @@ MaterialDef CartoonSSAO { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer NO_OUTLINE : disableOutline INSTANCING : useInstancing } diff --git a/jme3-vr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md b/jme3-vr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md index 79b7759237..427627732b 100644 --- a/jme3-vr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md +++ b/jme3-vr/src/main/resources/Common/MatDefs/VR/GuiOverlay.j3md @@ -1,6 +1,7 @@ MaterialDef GuiOverlay { MaterialParameters { + Int BoundDrawBuffer Texture2D ColorMap // For VR instancing @@ -8,8 +9,8 @@ MaterialDef GuiOverlay { } Technique { - VertexShader GLSL150: Common/MatDefs/VR/GuiOverlay15.vert - FragmentShader GLSL150: Common/MatDefs/VR/GuiOverlay15.frag + VertexShader GLSL300 GLSL150: Common/MatDefs/VR/GuiOverlay15.vert + FragmentShader GLSL300 GLSL150: Common/MatDefs/VR/GuiOverlay15.frag WorldParameters { WorldViewProjectionMatrix @@ -17,13 +18,14 @@ MaterialDef GuiOverlay { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : RightEyeViewProjectionMatrix // For VR instancing } } Technique { - VertexShader GLSL100: Common/MatDefs/VR/GuiOverlay.vert - FragmentShader GLSL100: Common/MatDefs/VR/GuiOverlay.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/GuiOverlay.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/GuiOverlay.frag WorldParameters { WorldViewProjectionMatrix @@ -31,6 +33,7 @@ MaterialDef GuiOverlay { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : RightEyeViewProjectionMatrix // For VR instancing } } diff --git a/jme3-vr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md b/jme3-vr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md index 7cadd0af08..c4385c91c0 100644 --- a/jme3-vr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md +++ b/jme3-vr/src/main/resources/Common/MatDefs/VR/OpenVR.j3md @@ -1,5 +1,6 @@ MaterialDef OpenVR { MaterialParameters { + Int BoundDrawBuffer Int NumSamples Texture2D Texture @@ -9,25 +10,27 @@ MaterialDef OpenVR { } Technique { - VertexShader GLSL150: Common/MatDefs/VR/OpenVR15.vert - FragmentShader GLSL150: Common/MatDefs/VR/OpenVR15.frag + VertexShader GLSL300 GLSL150: Common/MatDefs/VR/OpenVR15.vert + FragmentShader GLSL300 GLSL150: Common/MatDefs/VR/OpenVR15.frag WorldParameters { } Defines { - } + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } Technique { - VertexShader GLSL100: Common/MatDefs/VR/OpenVR.vert - FragmentShader GLSL100: Common/MatDefs/VR/OpenVR.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/OpenVR.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/OpenVR.frag WorldParameters { } Defines { - } + BOUND_DRAW_BUFFER: BoundDrawBuffer + } } } \ No newline at end of file diff --git a/jme3-vr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md b/jme3-vr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md index 3bdd5b2ea1..f85a94b047 100644 --- a/jme3-vr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md +++ b/jme3-vr/src/main/resources/Common/MatDefs/VR/PostShadowFilter.j3md @@ -1,6 +1,7 @@ MaterialDef Post Shadow { MaterialParameters { + Int BoundDrawBuffer Int FilterMode Boolean HardwareShadows @@ -46,14 +47,15 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL150: Common/MatDefs/VR/PostShadowFilter.vert - FragmentShader GLSL150: Common/MatDefs/VR/PostShadowFilter.frag + VertexShader GLSL300 GLSL150: Common/MatDefs/VR/PostShadowFilter.vert + FragmentShader GLSL300 GLSL150: Common/MatDefs/VR/PostShadowFilter.frag WorldParameters { ResolutionInverse } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer RESOLVE_MS : NumSamples RESOLVE_DEPTH_MS : NumSamplesDepth HARDWARE_SHADOWS : HardwareShadows @@ -72,14 +74,15 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadowFilter.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/Shadow/PostShadowFilter.frag WorldParameters { ResolutionInverse } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer HARDWARE_SHADOWS : HardwareShadows FILTER_MODE : FilterMode PCFEDGE : PCFEdge diff --git a/jme3-vr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md b/jme3-vr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md index 81e1ebecc4..13a9cf2b5e 100644 --- a/jme3-vr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md +++ b/jme3-vr/src/main/resources/Common/MatDefs/VR/Unshaded.j3md @@ -1,6 +1,7 @@ MaterialDef Unshaded { MaterialParameters { + Int BoundDrawBuffer Texture2D ColorMap Color Color (Color) @@ -9,8 +10,8 @@ MaterialDef Unshaded { } Technique { - VertexShader GLSL150: Common/MatDefs/VR/Unshaded.vert - FragmentShader GLSL150: Common/MatDefs/VR/Unshaded.frag + VertexShader GLSL300 GLSL150: Common/MatDefs/VR/Unshaded.vert + FragmentShader GLSL300 GLSL150: Common/MatDefs/VR/Unshaded.frag WorldParameters { WorldViewProjectionMatrix @@ -19,6 +20,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : RightEyeViewProjectionMatrix // For VR instancing HAS_COLORMAP : ColorMap HAS_COLOR : Color @@ -26,8 +28,8 @@ MaterialDef Unshaded { } Technique { - VertexShader GLSL100: Common/MatDefs/VR/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/VR/Unshaded.frag + VertexShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/Unshaded.vert + FragmentShader GLSL300 GLSL150 GLSL100: Common/MatDefs/VR/Unshaded.frag WorldParameters { WorldViewProjectionMatrix @@ -36,6 +38,7 @@ MaterialDef Unshaded { } Defines { + BOUND_DRAW_BUFFER: BoundDrawBuffer INSTANCING : RightEyeViewProjectionMatrix // For VR instancing HAS_COLORMAP : ColorMap HAS_COLOR : Color