Android openGL ES 3 support (#1147)
* Update GLImageFormats.java * Added basic support for openGL ES 3.0 and GLSL300 for android Added instancing support for android which is core feature in GLES3.0 Added fix for shadows in android * Fixed required types of GLES30.glDrawElementsInstanced * Properly check GLES3 version and setting precision for shaders for all GLSL ES versions * Added support for Opengl ES 3.1 and 3.2 and their shader versions Added proper checkings for new OpenGL ES versions Fixed some issues with shadow rendering in GLES 3.0 or better (strict type checking, OpenGL ES specific extensions and percision definition) Added GLSL320 and GLSL300 to Unshaded and Lighting materials * Added depth texture 24bit for OpenGL ES * Added geometry shaders and tessellation to GLES 3.1 as extension and GLES 3.2 as core Modified test materials to use GLSL310 * Added FB blit for android GLES30 * Added GlSL300 or better to all effects not able to run in GLSL100 Mods on Shadows.glsllib to try to fix android shadow rendering Fixed ssaoBlur.frag that was using a reserved word Fixed precision type missmatch from vertex to fragment shader * Partial multisample support Framebuffer MRT support * Temporarily removed texture multisampling (not being able to compile using GLES31) * Updated android.jar to api28 Enabled multisampling * Better checking for GLES3 * Removed insert precision for all shaders. This avoided some random precision missmatch error but created rendering issues * Removed border check for GLES, caused filtered shadows not to render on GLES2.0 devices Added texture compare mode for GLES3.0 and better to be able to use sampler2DShadow Modified base materials (Lighting and Unshaded) to use only GLSL100 for post shadow pass * Corrected texture comparison function that were incorrectly changed * Added precision to samplers for GLESSL300 also * Created a subclass of Glsl150ShaderGenerator (Glsl300ShaderGenerator) to support ShaderNodes in GLES SL30 and included it's usage in DesktopAssetManager. Nowadays just copied and overwrote the version string. Needs a full review Added image format RGB16F to be used as texture format only in GLES30 (cannot be used as FB format) Added GLSL300 and/or GLSL310 to different materials * Cleaned GLSL300 generator Fixed shadows glsl lib removing use of GL_EXT_gpu_shaders5 * Fixed usag of textureCubeLod in fragment shader of envMapping which is unsupported in GLES2.0 Modified PBRLighting frag to properly compile on GLES3 * Added GLSL300 and 310 to PostShadowFilter material definition * Make post shadow filter use GLSL100 for GLSL300 Set highp as default precision to fix glitched shadows caused because not enough precision * Changed water_normalmap.dds to uncompressed RGB8 because DXT1 is mostly unsupported in GLES * Fixed GLES30 compilation issues in Water shaders and added GLSL300 to LightScattering material. ** Not fully tested * Added RGB8 dds formatted FullskiesSunset to be used in any platform. Previous file moved to _dtx1.dds * Set GL_TEXTURE_MAX_LEVEL in GLES30 contexts fixing issue with not fully mipmapped images and PBR rendering * Fixed compilation of jme3-android-examples and upgraded sdk version to use * Fixed Geometry Shader and Tessellation Shaders in testdata package to properly compile on GLES320 * Added non-compressed textures to be able to run all examples on android Enabled texture arrays and 3d textures on opengl es 3.0. Peding to implement wrappers to android gl functions (currently getting NullPointerException) * More GLES30 functions included to properly support texture arrays, 3d textures and multisampling matching jme core code * Fixed 3D texture tests for GLES30 Fixed texture 3D and texture array example shader compilation on GLES30 Fixed some random missing precision compilation errors on GLES30 * Fixed TestTextureArray for GLES30 * Some multisample additions and removal of GLES3 multisampling enable caps Added RGBA16F as valid format for GLES32 and using it by default in env camera instead of RGB16F. kept fall back to RGB8 * added float and half float formats for gles30 added rgb10a2 format for gles30 fixed usage of glTexImage2D removed EnvironmentCamera fallback image format as it's useless now * Added more image formats for GLES30 Fixed rgb8 if having Caps.Rgba8 * Enabled RadialBlur for gles30 * Fixed luminance texture formats for gles * Added more depth image formats for gles3 * Enabled multisampling in gles3 * Added GLES30 functions to GLDebugES Reverted TestTexture3D and TestTextureArray to use RGB8 format Updated EnvMapping100.frag to use EXT_shader_texture_lod in gles sl 100 if available * Removed all aditional not used compressed dds files Removed also Pond and rock png files previously used in TestTextureArray * Removed compressed water_normalmap_dxt1.dds * Changed GLES_30 and AndroidGL implementing GL2 to avoid duplicated code checking GL2 vs GLES30 * Added aditional checking to avoid gles30 calls from gles20 only devices
This commit is contained in:
parent
7ae1ff23af
commit
663c9776e8
@ -12,6 +12,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'base'
|
||||
apply from: file('version.gradle')
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion "28.0.3"
|
||||
|
||||
lintOptions {
|
||||
// Fix nifty gui referencing "java.awt" package.
|
||||
@ -13,7 +13,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "org.jmonkeyengine.jme3androidexamples"
|
||||
minSdkVersion 15 // Android 4.0.3 ICE CREAM SANDWICH
|
||||
targetSdkVersion 22 // Android 5.1 LOLLIPOP
|
||||
targetSdkVersion 28 // Android 9 PIE
|
||||
versionCode 1
|
||||
versionName "1.0" // TODO: from settings.gradle
|
||||
}
|
||||
@ -25,6 +25,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
@ -42,7 +47,7 @@ android {
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
||||
compile 'com.android.support:appcompat-v7:28.0.0'
|
||||
|
||||
compile project(':jme3-core')
|
||||
compile project(':jme3-android')
|
||||
|
@ -62,15 +62,15 @@ public class JmeFragment extends AndroidHarnessFragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Bundle bundle=getArguments();
|
||||
|
||||
appClass = bundle.getString(SELECTED_APP_CLASS);
|
||||
appClass = bundle.getString(MainActivity.SELECTED_APP_CLASS);
|
||||
// Log.d(this.getClass().getSimpleName(), "AppClass: " + appClass);
|
||||
joystickEventsEnabled = bundle.getBoolean(ENABLE_JOYSTICK_EVENTS);
|
||||
joystickEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS);
|
||||
// Log.d(this.getClass().getSimpleName(), "JoystickEventsEnabled: " + joystickEventsEnabled);
|
||||
keyEventsEnabled = bundle.getBoolean(ENABLE_KEY_EVENTS);
|
||||
keyEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_KEY_EVENTS);
|
||||
// Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled);
|
||||
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS);
|
||||
mouseEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS);
|
||||
// Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled);
|
||||
boolean verboseLogging = bundle.getBoolean(VERBOSE_LOGGING);
|
||||
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING);
|
||||
// Log.d(this.getClass().getSimpleName(), "VerboseLogging: " + verboseLogging);
|
||||
if (verboseLogging) {
|
||||
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
|
||||
|
@ -34,6 +34,7 @@ package com.jme3.renderer.android;
|
||||
import android.opengl.*;
|
||||
import com.jme3.renderer.RendererException;
|
||||
import com.jme3.renderer.opengl.*;
|
||||
import com.jme3.util.BufferUtils;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -41,7 +42,9 @@ import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
public class AndroidGL implements GL, GL2, GLES_30, GLExt, GLFbo {
|
||||
|
||||
IntBuffer tmpBuff = BufferUtils.createIntBuffer(1);
|
||||
|
||||
public void resetStats() {
|
||||
}
|
||||
@ -361,7 +364,7 @@ public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
}
|
||||
|
||||
public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, ByteBuffer data) {
|
||||
GLES20.glTexImage2D(target, level, format, width, height, 0, format, type, data);
|
||||
GLES20.glTexImage2D(target, level, internalFormat, width, height, 0, format, type, data);
|
||||
}
|
||||
|
||||
public void glTexParameterf(int target, int pname, float param) {
|
||||
@ -449,7 +452,7 @@ public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
}
|
||||
|
||||
public void glBlitFramebufferEXT(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) {
|
||||
throw new UnsupportedOperationException("FBO blit not available on Android");
|
||||
GLES30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
public void glBufferData(int target, IntBuffer data, int usage) {
|
||||
@ -461,31 +464,31 @@ public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
}
|
||||
|
||||
public void glDrawArraysInstancedARB(int mode, int first, int count, int primcount) {
|
||||
throw new UnsupportedOperationException("Instancing not available on Android");
|
||||
GLES30.glDrawArraysInstanced(mode, first, count, primcount);
|
||||
}
|
||||
|
||||
public void glDrawBuffers(IntBuffer bufs) {
|
||||
throw new UnsupportedOperationException("MRT not available on Android");
|
||||
GLES30.glDrawBuffers(bufs.limit(), bufs);
|
||||
}
|
||||
|
||||
public void glDrawElementsInstancedARB(int mode, int indices_count, int type, long indices_buffer_offset, int primcount) {
|
||||
throw new UnsupportedOperationException("Instancing not available on Android");
|
||||
GLES30.glDrawElementsInstanced(mode, indices_count, type, (int)indices_buffer_offset, primcount);
|
||||
}
|
||||
|
||||
public void glGetMultisample(int pname, int index, FloatBuffer val) {
|
||||
throw new UnsupportedOperationException("Multisample renderbuffers not available on Android");
|
||||
GLES31.glGetMultisamplefv(pname, index, val);
|
||||
}
|
||||
|
||||
public void glRenderbufferStorageMultisampleEXT(int target, int samples, int internalformat, int width, int height) {
|
||||
throw new UnsupportedOperationException("Multisample renderbuffers not available on Android");
|
||||
GLES30.glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
|
||||
}
|
||||
|
||||
public void glTexImage2DMultisample(int target, int samples, int internalformat, int width, int height, boolean fixedsamplelocations) {
|
||||
throw new UnsupportedOperationException("Multisample textures not available on Android");
|
||||
GLES31.glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
|
||||
}
|
||||
|
||||
public void glVertexAttribDivisorARB(int index, int divisor) {
|
||||
throw new UnsupportedOperationException("Instancing not available on Android");
|
||||
GLES30.glVertexAttribDivisor(index, divisor);
|
||||
}
|
||||
|
||||
public void glBindFramebufferEXT(int param1, int param2) {
|
||||
@ -564,6 +567,49 @@ public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
|
||||
@Override
|
||||
public void glFramebufferTextureLayerEXT(int target, int attachment, int texture, int level, int layer) {
|
||||
throw new UnsupportedOperationException("OpenGL ES 2 does not support texture arrays");
|
||||
GLES30.glFramebufferTextureLayer(target, attachment, texture, level, layer);
|
||||
}
|
||||
|
||||
public void glAlphaFunc(int func, float ref) {
|
||||
}
|
||||
|
||||
public void glPointSize(float size) {
|
||||
}
|
||||
|
||||
public void glPolygonMode(int face, int mode) {
|
||||
}
|
||||
|
||||
// Wrapper to DrawBuffers as there's no DrawBuffer method in GLES
|
||||
public void glDrawBuffer(int mode) {
|
||||
tmpBuff.clear();
|
||||
tmpBuff.put(0, mode);
|
||||
tmpBuff.rewind();
|
||||
glDrawBuffers(tmpBuff);
|
||||
}
|
||||
|
||||
public void glReadBuffer(int mode) {
|
||||
GLES30.glReadBuffer(mode);
|
||||
}
|
||||
|
||||
public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
|
||||
int border, ByteBuffer data) {
|
||||
GLES30.glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, getLimitBytes(data), data);
|
||||
}
|
||||
|
||||
public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width,
|
||||
int height, int depth, int format, ByteBuffer data) {
|
||||
GLES30.glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, getLimitBytes(data), data);
|
||||
}
|
||||
|
||||
public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border,
|
||||
int format, int type, ByteBuffer data) {
|
||||
GLES30.glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
|
||||
}
|
||||
|
||||
public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height,
|
||||
int depth, int format, int type, ByteBuffer data) {
|
||||
GLES30.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
||||
private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
|
||||
protected AppSettings settings;
|
||||
private final static int EGL_OPENGL_ES2_BIT = 4;
|
||||
private final static int EGL_OPENGL_ES3_BIT = 0x40;
|
||||
|
||||
public AndroidConfigChooser(AppSettings settings) {
|
||||
this.settings = settings;
|
||||
@ -140,12 +141,29 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
||||
|
||||
int[] num_config = new int[1];
|
||||
int[] configSpec = new int[]{
|
||||
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
|
||||
EGL10.EGL_NONE};
|
||||
boolean gles3=true;
|
||||
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
|
||||
RendererUtil.checkEGLError(egl);
|
||||
throw new AssertionError();
|
||||
// Try openGL ES 3
|
||||
try {
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
|
||||
RendererUtil.checkEGLError(egl);
|
||||
gles3=false;
|
||||
}
|
||||
} catch (com.jme3.renderer.RendererException re) {
|
||||
// it's just the device not supporting GLES3. Fallback to GLES2
|
||||
gles3=false;
|
||||
}
|
||||
|
||||
if(!gles3)
|
||||
{
|
||||
// Get back to openGL ES 2
|
||||
configSpec[1]=EGL_OPENGL_ES2_BIT;
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
|
||||
RendererUtil.checkEGLError(egl);
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
int numConfigs = num_config[0];
|
||||
|
@ -53,6 +53,7 @@ import com.jme3.input.dummy.DummyKeyInput;
|
||||
import com.jme3.input.dummy.DummyMouseInput;
|
||||
import com.jme3.renderer.android.AndroidGL;
|
||||
import com.jme3.renderer.opengl.GL;
|
||||
import com.jme3.renderer.opengl.GLES_30;
|
||||
import com.jme3.renderer.opengl.GLDebugES;
|
||||
import com.jme3.renderer.opengl.GLExt;
|
||||
import com.jme3.renderer.opengl.GLFbo;
|
||||
@ -99,13 +100,13 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
||||
* @return GLSurfaceView The newly created view
|
||||
*/
|
||||
public GLSurfaceView createView(Context context) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ConfigurationInfo info = am.getDeviceConfigurationInfo();
|
||||
// NOTE: We assume all ICS devices have OpenGL ES 2.0.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
// below 4.0, check OpenGL ES 2.0 support.
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ConfigurationInfo info = am.getDeviceConfigurationInfo();
|
||||
if (info.reqGlEsVersion < 0x20000) {
|
||||
throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
|
||||
throw new UnsupportedOperationException("OpenGL ES 2.0 or better is not supported on this device");
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT < 9){
|
||||
throw new UnsupportedOperationException("jME3 requires Android 2.3 or later");
|
||||
@ -126,7 +127,8 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
||||
|
||||
// setEGLContextClientVersion must be set before calling setRenderer
|
||||
// this means it cannot be set in AndroidConfigChooser (too late)
|
||||
view.setEGLContextClientVersion(2);
|
||||
// use proper openGL ES version
|
||||
view.setEGLContextClientVersion(info.reqGlEsVersion>>16);
|
||||
|
||||
view.setFocusableInTouchMode(true);
|
||||
view.setFocusable(true);
|
||||
@ -201,7 +203,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
||||
gl = new GLDebugES((GL) gl, (GLExt) gl, (GLFbo) gl);
|
||||
}
|
||||
if (settings.getBoolean("GraphicsTrace")) {
|
||||
gl = GLTracer.createGlesTracer(gl, GL.class, GLFbo.class, GLExt.class);
|
||||
gl = GLTracer.createGlesTracer(gl, GL.class, GLES_30.class, GLFbo.class, GLExt.class);
|
||||
}
|
||||
renderer = new GLRenderer((GL)gl, (GLExt)gl, (GLFbo)gl);
|
||||
renderer.initialize();
|
||||
|
@ -41,6 +41,7 @@ import com.jme3.renderer.Caps;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.shader.Glsl100ShaderGenerator;
|
||||
import com.jme3.shader.Glsl150ShaderGenerator;
|
||||
import com.jme3.shader.Glsl300ShaderGenerator;
|
||||
import com.jme3.shader.ShaderGenerator;
|
||||
import com.jme3.system.JmeSystem;
|
||||
import com.jme3.texture.Texture;
|
||||
@ -434,7 +435,9 @@ public class DesktopAssetManager implements AssetManager {
|
||||
@Override
|
||||
public ShaderGenerator getShaderGenerator(EnumSet<Caps> caps) {
|
||||
if (shaderGenerator == null) {
|
||||
if(caps.contains(Caps.GLSL150)){
|
||||
if(caps.contains(Caps.OpenGLES30) && caps.contains(Caps.GLSL300)){
|
||||
shaderGenerator = new Glsl300ShaderGenerator(this);
|
||||
}else if(caps.contains(Caps.GLSL150)) {
|
||||
shaderGenerator = new Glsl150ShaderGenerator(this);
|
||||
}else{
|
||||
shaderGenerator = new Glsl100ShaderGenerator(this);
|
||||
|
@ -403,7 +403,45 @@ public enum Caps {
|
||||
/**
|
||||
* Supporting working with ShaderStorageBufferObjects.
|
||||
*/
|
||||
ShaderStorageBufferObject;
|
||||
ShaderStorageBufferObject,
|
||||
|
||||
/**
|
||||
* Supports OpenGL ES 3.0
|
||||
*/
|
||||
OpenGLES30,
|
||||
|
||||
/**
|
||||
* Supports GLSL 3.0
|
||||
*/
|
||||
GLSL300,
|
||||
|
||||
/**
|
||||
* Supports OpenGL ES 3.1
|
||||
*/
|
||||
OpenGLES31,
|
||||
|
||||
/**
|
||||
* Supports GLSL 3.1
|
||||
*/
|
||||
GLSL310,
|
||||
|
||||
/**
|
||||
* Supports OpenGL ES 3.2
|
||||
*/
|
||||
OpenGLES32,
|
||||
|
||||
/**
|
||||
* Supports GLSL 3.2
|
||||
*/
|
||||
GLSL320,
|
||||
|
||||
/**
|
||||
* Explicit support of depth 24 textures
|
||||
*/
|
||||
Depth24;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if given the renderer capabilities, the texture
|
||||
|
@ -5,7 +5,7 @@ import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class GLDebugES extends GLDebug implements GL, GLFbo, GLExt {
|
||||
public class GLDebugES extends GLDebug implements GL, GL2, GLES_30, GLFbo, GLExt {
|
||||
|
||||
private final GLFbo glfbo;
|
||||
private final GLExt glext;
|
||||
@ -609,4 +609,54 @@ public class GLDebugES extends GLDebug implements GL, GLFbo, GLExt {
|
||||
glfbo.glFramebufferTextureLayerEXT(param1, param2, param3, param4, param5);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glAlphaFunc(int func, float ref) {
|
||||
((GL2)gl).glAlphaFunc(func, ref);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glPointSize(float size) {
|
||||
((GL2)gl).glPointSize(size);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glPolygonMode(int face, int mode) {
|
||||
((GL2)gl).glPolygonMode(face, mode);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glDrawBuffer(int mode) {
|
||||
((GL2)gl).glDrawBuffer(mode);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glReadBuffer(int mode) {
|
||||
((GL2)gl).glReadBuffer(mode);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
|
||||
int border, ByteBuffer data) {
|
||||
((GL2)gl).glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, data);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width,
|
||||
int height, int depth, int format, ByteBuffer data) {
|
||||
((GL2)gl).glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, data);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border,
|
||||
int format, int type, ByteBuffer data) {
|
||||
((GL2)gl).glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
|
||||
checkError();
|
||||
}
|
||||
|
||||
public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height,
|
||||
int depth, int format, int type, ByteBuffer data) {
|
||||
((GL2)gl).glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
|
||||
checkError();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2019 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jme3.renderer.opengl;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* GL functions and constants only available on vanilla OpenGL ES 3.0.
|
||||
*
|
||||
* @author Jesus Oliver
|
||||
*/
|
||||
public interface GLES_30 extends GL {
|
||||
|
||||
public static final int GL_RGB10_A2 = 0x8059;
|
||||
public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
|
||||
|
||||
}
|
@ -166,7 +166,7 @@ public final class GLImageFormats {
|
||||
format(formatToGL, Format.Luminance8, GLExt.GL_RGBA8, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE);
|
||||
format(formatToGL, Format.Luminance8Alpha8, GLExt.GL_RGBA8, GL.GL_LUMINANCE_ALPHA, GL.GL_UNSIGNED_BYTE);
|
||||
}
|
||||
format(formatToGL, Format.RGB8, GLExt.GL_RGBA8, GL.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
||||
format(formatToGL, Format.RGB8, GL2.GL_RGB8, GL.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
||||
format(formatToGL, Format.RGBA8, GLExt.GL_RGBA8, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE);
|
||||
|
||||
formatSwiz(formatToGL, Format.BGR8, GL2.GL_RGB8, GL2.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
||||
@ -217,8 +217,28 @@ public final class GLImageFormats {
|
||||
format(formatToGL, Format.RGB16F_to_RGB9E5, GLExt.GL_RGB9_E5_EXT, GL.GL_RGB, halfFloatFormat);
|
||||
}
|
||||
}
|
||||
|
||||
// Supported in GLES30 core
|
||||
if (caps.contains(Caps.OpenGLES30)) {
|
||||
format(formatToGL, Format.RGB10A2, GLES_30.GL_RGB10_A2, GL.GL_RGBA, GLES_30.GL_UNSIGNED_INT_2_10_10_10_REV);
|
||||
format(formatToGL, Format.Alpha8, GL2.GL_ALPHA8, GL.GL_ALPHA, GL.GL_UNSIGNED_BYTE);
|
||||
format(formatToGL, Format.Luminance8, GL.GL_LUMINANCE, GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE);
|
||||
format(formatToGL, Format.Luminance8Alpha8, GL.GL_LUMINANCE_ALPHA, GL.GL_LUMINANCE_ALPHA, GL.GL_UNSIGNED_BYTE);
|
||||
|
||||
formatSrgb(formatToGL, Format.RGB8, GLExt.GL_SRGB8_EXT, GL.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
||||
formatSrgb(formatToGL, Format.RGBA8, GLExt.GL_SRGB8_ALPHA8_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE);
|
||||
|
||||
//Depending on the device could be better to use the previously defined extension based float textures instead of gles3.0 texture formats
|
||||
// if (!caps.contains(Caps.FloatTexture)) {
|
||||
format(formatToGL, Format.RGB16F, GLExt.GL_RGB16F_ARB, GL.GL_RGB, GLExt.GL_HALF_FLOAT_ARB);
|
||||
format(formatToGL, Format.RGB32F, GLExt.GL_RGB32F_ARB, GL.GL_RGB, GL.GL_FLOAT);
|
||||
format(formatToGL, Format.RGBA16F, GLExt.GL_RGBA16F_ARB, GL.GL_RGBA, GLExt.GL_HALF_FLOAT_ARB);
|
||||
format(formatToGL, Format.RGBA32F, GLExt.GL_RGBA32F_ARB, GL.GL_RGBA, GL.GL_FLOAT);
|
||||
// }
|
||||
format(formatToGL, Format.RGB111110F, GLExt.GL_R11F_G11F_B10F_EXT, GL.GL_RGB, GLExt.GL_UNSIGNED_INT_10F_11F_11F_REV_EXT);
|
||||
}
|
||||
|
||||
// Need to check if Caps.DepthTexture is supported prior to using for textures
|
||||
// Need to check if Caps.DepthTexture is supported prior to using for textures
|
||||
// But for renderbuffers its OK.
|
||||
format(formatToGL, Format.Depth16, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_SHORT);
|
||||
|
||||
@ -228,7 +248,7 @@ public final class GLImageFormats {
|
||||
} else {
|
||||
format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE);
|
||||
}
|
||||
if (caps.contains(Caps.OpenGL20)) {
|
||||
if (caps.contains(Caps.OpenGL20) || caps.contains(Caps.Depth24)) {
|
||||
format(formatToGL, Format.Depth24, GL2.GL_DEPTH_COMPONENT24, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT);
|
||||
}
|
||||
if (caps.contains(Caps.FloatDepthBuffer)) {
|
||||
|
@ -71,6 +71,7 @@ import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public final class GLRenderer implements Renderer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(GLRenderer.class.getName());
|
||||
@ -166,9 +167,28 @@ public final class GLRenderer implements Renderer {
|
||||
}
|
||||
|
||||
private void loadCapabilitiesES() {
|
||||
int oglVer = extractVersion(gl.glGetString(GL.GL_VERSION));
|
||||
caps.add(Caps.GLSL100);
|
||||
caps.add(Caps.OpenGLES20);
|
||||
|
||||
caps.add(Caps.Multisample);
|
||||
|
||||
if (oglVer >= 300) {
|
||||
caps.add(Caps.OpenGLES30);
|
||||
caps.add(Caps.GLSL300);
|
||||
// Instancing is core in GLES300
|
||||
caps.add(Caps.MeshInstancing);
|
||||
}
|
||||
if (oglVer >= 310) {
|
||||
caps.add(Caps.OpenGLES31);
|
||||
caps.add(Caps.GLSL310);
|
||||
}
|
||||
if (oglVer >= 320) {
|
||||
caps.add(Caps.OpenGLES32);
|
||||
caps.add(Caps.GLSL320);
|
||||
caps.add(Caps.GeometryShader);
|
||||
caps.add(Caps.TesselationShader);
|
||||
}
|
||||
// Important: Do not add OpenGL20 - that's the desktop capability!
|
||||
}
|
||||
|
||||
@ -293,6 +313,7 @@ public final class GLRenderer implements Renderer {
|
||||
|
||||
if (hasExtension("GL_ARB_draw_instanced") &&
|
||||
hasExtension("GL_ARB_instanced_arrays")) {
|
||||
// TODO: If there were a way to call the EXT extension for GLES2, should check also (hasExtension("GL_EXT_draw_instanced") && hasExtension("GL_EXT_instanced_arrays"))
|
||||
caps.add(Caps.MeshInstancing);
|
||||
}
|
||||
|
||||
@ -330,8 +351,10 @@ public final class GLRenderer implements Renderer {
|
||||
|
||||
if (hasExtension("GL_OES_depth_texture") || gl2 != null) {
|
||||
caps.add(Caps.DepthTexture);
|
||||
}
|
||||
|
||||
// TODO: GL_OES_depth24
|
||||
if (hasExtension("GL_OES_depth24")) {
|
||||
caps.add(Caps.Depth24);
|
||||
}
|
||||
|
||||
if (hasExtension("GL_OES_rgb8_rgba8") ||
|
||||
@ -340,7 +363,7 @@ public final class GLRenderer implements Renderer {
|
||||
caps.add(Caps.Rgba8);
|
||||
}
|
||||
|
||||
if (caps.contains(Caps.OpenGL30) || hasExtension("GL_OES_packed_depth_stencil")) {
|
||||
if (caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30) || hasExtension("GL_OES_packed_depth_stencil")) {
|
||||
caps.add(Caps.PackedDepthStencilBuffer);
|
||||
}
|
||||
|
||||
@ -350,7 +373,7 @@ public final class GLRenderer implements Renderer {
|
||||
caps.add(Caps.FloatColorBuffer);
|
||||
}
|
||||
|
||||
if (hasExtension("GL_ARB_depth_buffer_float")) {
|
||||
if (caps.contains(Caps.OpenGLES30) || hasExtension("GL_ARB_depth_buffer_float")) {
|
||||
caps.add(Caps.FloatDepthBuffer);
|
||||
}
|
||||
|
||||
@ -397,7 +420,7 @@ public final class GLRenderer implements Renderer {
|
||||
caps.add(Caps.PartialNonPowerOfTwoTextures);
|
||||
}
|
||||
|
||||
if (hasExtension("GL_EXT_texture_array") || caps.contains(Caps.OpenGL30)) {
|
||||
if (hasExtension("GL_EXT_texture_array") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) {
|
||||
caps.add(Caps.TextureArray);
|
||||
}
|
||||
|
||||
@ -414,16 +437,16 @@ public final class GLRenderer implements Renderer {
|
||||
limits.put(Limits.RenderBufferSize, getInteger(GLFbo.GL_MAX_RENDERBUFFER_SIZE_EXT));
|
||||
limits.put(Limits.FrameBufferAttachments, getInteger(GLFbo.GL_MAX_COLOR_ATTACHMENTS_EXT));
|
||||
|
||||
if (hasExtension("GL_EXT_framebuffer_blit") || caps.contains(Caps.OpenGL30)) {
|
||||
if (hasExtension("GL_EXT_framebuffer_blit") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) {
|
||||
caps.add(Caps.FrameBufferBlit);
|
||||
}
|
||||
|
||||
if (hasExtension("GL_EXT_framebuffer_multisample")) {
|
||||
if (hasExtension("GL_EXT_framebuffer_multisample") || caps.contains(Caps.OpenGLES30)) {
|
||||
caps.add(Caps.FrameBufferMultisample);
|
||||
limits.put(Limits.FrameBufferSamples, getInteger(GLExt.GL_MAX_SAMPLES_EXT));
|
||||
}
|
||||
|
||||
if (hasExtension("GL_ARB_texture_multisample")) {
|
||||
if (hasExtension("GL_ARB_texture_multisample") || caps.contains(Caps.OpenGLES31)) { // GLES31 does not fully support it
|
||||
caps.add(Caps.TextureMultisample);
|
||||
limits.put(Limits.ColorTextureSamples, getInteger(GLExt.GL_MAX_COLOR_TEXTURE_SAMPLES));
|
||||
limits.put(Limits.DepthTextureSamples, getInteger(GLExt.GL_MAX_DEPTH_TEXTURE_SAMPLES));
|
||||
@ -432,8 +455,8 @@ public final class GLRenderer implements Renderer {
|
||||
limits.put(Limits.FrameBufferSamples, limits.get(Limits.ColorTextureSamples));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasExtension("GL_ARB_draw_buffers") || caps.contains(Caps.OpenGL30)) {
|
||||
|
||||
if (hasExtension("GL_ARB_draw_buffers") || caps.contains(Caps.OpenGL30) || caps.contains(Caps.OpenGLES30)) {
|
||||
limits.put(Limits.FrameBufferMrtAttachments, getInteger(GLExt.GL_MAX_DRAW_BUFFERS_ARB));
|
||||
if (limits.get(Limits.FrameBufferMrtAttachments) > 1) {
|
||||
caps.add(Caps.FrameBufferMRT);
|
||||
@ -443,7 +466,7 @@ public final class GLRenderer implements Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
if (hasExtension("GL_ARB_multisample")) {
|
||||
if (hasExtension("GL_ARB_multisample") /*|| caps.contains(Caps.OpenGLES20)*/) {
|
||||
boolean available = getInteger(GLExt.GL_SAMPLE_BUFFERS_ARB) != 0;
|
||||
int samples = getInteger(GLExt.GL_SAMPLES_ARB);
|
||||
logger.log(Level.FINER, "Samples: {0}", samples);
|
||||
@ -498,6 +521,14 @@ public final class GLRenderer implements Renderer {
|
||||
limits.put(Limits.UniformBufferObjectMaxVertexBlocks, getInteger(GL3.GL_MAX_VERTEX_UNIFORM_BLOCKS));
|
||||
}
|
||||
|
||||
if (hasExtension("GL_OES_geometry_shader") || hasExtension("GL_EXT_geometry_shader")) {
|
||||
caps.add(Caps.GeometryShader);
|
||||
}
|
||||
|
||||
if (hasExtension("GL_OES_tessellation_shader") || hasExtension("GL_EXT_tessellation_shader")) {
|
||||
caps.add(Caps.TesselationShader);
|
||||
}
|
||||
|
||||
// Print context information
|
||||
logger.log(Level.INFO, "OpenGL Renderer Information\n" +
|
||||
" * Vendor: {0}\n" +
|
||||
@ -539,7 +570,7 @@ public final class GLRenderer implements Renderer {
|
||||
}
|
||||
|
||||
private void loadCapabilities() {
|
||||
if (gl2 != null) {
|
||||
if (gl2 != null && !(gl instanceof GLES_30)) {
|
||||
loadCapabilitiesGL2();
|
||||
} else {
|
||||
loadCapabilitiesES();
|
||||
@ -1327,10 +1358,11 @@ public final class GLRenderer implements Renderer {
|
||||
throw new RendererException("Cannot recompile shader source");
|
||||
}
|
||||
|
||||
boolean gles3 = caps.contains(Caps.OpenGLES30);
|
||||
boolean gles2 = caps.contains(Caps.OpenGLES20);
|
||||
String language = source.getLanguage();
|
||||
|
||||
if (gles2 && !language.equals("GLSL100")) {
|
||||
if (!gles3 && gles2 && !language.equals("GLSL100")) { //avoid this check for gles3
|
||||
throw new RendererException("This shader cannot run in OpenGL ES 2. "
|
||||
+ "Only GLSL 1.00 shaders are supported.");
|
||||
}
|
||||
@ -1339,24 +1371,25 @@ public final class GLRenderer implements Renderer {
|
||||
// Upload shader source.
|
||||
// Merge the defines and source code.
|
||||
stringBuf.setLength(0);
|
||||
int version = Integer.parseInt(language.substring(4));
|
||||
if (language.startsWith("GLSL")) {
|
||||
int version = Integer.parseInt(language.substring(4));
|
||||
if (version > 100) {
|
||||
stringBuf.append("#version ");
|
||||
stringBuf.append(language.substring(4));
|
||||
if (version >= 150) {
|
||||
stringBuf.append(" core");
|
||||
if(gles3) {
|
||||
stringBuf.append(" es");
|
||||
}
|
||||
else {
|
||||
stringBuf.append(" core");
|
||||
}
|
||||
}
|
||||
stringBuf.append("\n");
|
||||
} else {
|
||||
if (gles2) {
|
||||
if (gles2 || gles3) {
|
||||
// request GLSL ES (1.00) when compiling under GLES2.
|
||||
stringBuf.append("#version 100\n");
|
||||
|
||||
if (source.getType() == ShaderType.Fragment) {
|
||||
// GLES2 requires precision qualifier.
|
||||
insertPrecision = true;
|
||||
}
|
||||
} else {
|
||||
// version 100 does not exist in desktop GLSL.
|
||||
// put version 110 in that case to enable strict checking
|
||||
@ -1364,6 +1397,15 @@ public final class GLRenderer implements Renderer {
|
||||
stringBuf.append("#version 110\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (gles2 || gles3) {
|
||||
//Inserting precision only to fragment shaders creates some link failures because of different precision between shaders
|
||||
//But adding the precision to all shaders generates rendering glitches in some devices if not set to highp
|
||||
if (source.getType() == ShaderType.Fragment) {
|
||||
// GLES requires precision qualifier.
|
||||
insertPrecision = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (linearizeSrgbImages) {
|
||||
@ -1375,11 +1417,22 @@ public final class GLRenderer implements Renderer {
|
||||
stringBuf.append(source.getSource());
|
||||
|
||||
if(insertPrecision){
|
||||
// default precision could be defined in GLSLCompat.glsllib so final users can use custom defined precision instead
|
||||
// precision token is not a preprocessor dirrective therefore it must be placed after #extension tokens to avoid
|
||||
// Error P0001: Extension directive must occur before any non-preprocessor tokens
|
||||
int idx = stringBuf.lastIndexOf("#extension");
|
||||
idx = stringBuf.indexOf("\n", idx);
|
||||
stringBuf.insert(idx + 1, "precision mediump float;\n");
|
||||
|
||||
if(version>=310) {
|
||||
stringBuf.insert(idx + 1, "precision highp sampler2DMS;\n");
|
||||
}
|
||||
if(version>=300) {
|
||||
stringBuf.insert(idx + 1, "precision highp sampler2DArray;\n");
|
||||
stringBuf.insert(idx + 1, "precision highp sampler2DShadow;\n");
|
||||
stringBuf.insert(idx + 1, "precision highp sampler3D;\n");
|
||||
stringBuf.insert(idx + 1, "precision highp sampler2D;\n");
|
||||
}
|
||||
stringBuf.insert(idx + 1, "precision highp float;\n");
|
||||
}
|
||||
|
||||
intBuf1.clear();
|
||||
@ -1612,6 +1665,7 @@ public final class GLRenderer implements Renderer {
|
||||
if (copyDepth) {
|
||||
mask |= GL.GL_DEPTH_BUFFER_BIT;
|
||||
}
|
||||
|
||||
glfbo.glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1,
|
||||
dstX0, dstY0, dstX1, dstY1, mask,
|
||||
GL.GL_NEAREST);
|
||||
@ -1842,7 +1896,7 @@ public final class GLRenderer implements Renderer {
|
||||
}
|
||||
|
||||
public void setReadDrawBuffers(FrameBuffer fb) {
|
||||
if (gl2 == null) {
|
||||
if (gl2 == null || gl instanceof GLES_30) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1982,6 +2036,7 @@ public final class GLRenderer implements Renderer {
|
||||
context.boundReadBuf = rb.getSlot();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
setFrameBuffer(null);
|
||||
}
|
||||
@ -2048,7 +2103,7 @@ public final class GLRenderer implements Renderer {
|
||||
return GLExt.GL_TEXTURE_2D_ARRAY_EXT;
|
||||
}
|
||||
case ThreeDimensional:
|
||||
if (!caps.contains(Caps.OpenGL20)) {
|
||||
if (!caps.contains(Caps.OpenGL20) && !caps.contains(Caps.OpenGLES30)) {
|
||||
throw new RendererException("3D textures are not supported" +
|
||||
" by the video hardware.");
|
||||
}
|
||||
@ -2172,9 +2227,9 @@ public final class GLRenderer implements Renderer {
|
||||
switch (tex.getType()) {
|
||||
case ThreeDimensional:
|
||||
case CubeMap: // cubemaps use 3D coords
|
||||
if (gl2 != null && curState.rWrap != tex.getWrap(WrapAxis.R)) {
|
||||
if (gl2 != null && (caps.contains(Caps.OpenGL20) || caps.contains(Caps.OpenGLES30)) && curState.rWrap != tex.getWrap(WrapAxis.R)) {
|
||||
bindTextureAndUnit(target, image, unit);
|
||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
|
||||
gl.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
|
||||
curState.rWrap = tex.getWrap(WrapAxis.R);
|
||||
}
|
||||
//There is no break statement on purpose here
|
||||
@ -2196,17 +2251,17 @@ public final class GLRenderer implements Renderer {
|
||||
}
|
||||
|
||||
ShadowCompareMode texCompareMode = tex.getShadowCompareMode();
|
||||
if (gl2 != null && curState.shadowCompareMode != texCompareMode) {
|
||||
if ( (gl2 != null || caps.contains(Caps.OpenGLES30)) && curState.shadowCompareMode != texCompareMode) {
|
||||
bindTextureAndUnit(target, image, unit);
|
||||
if (texCompareMode != ShadowCompareMode.Off) {
|
||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE);
|
||||
gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE);
|
||||
if (texCompareMode == ShadowCompareMode.GreaterOrEqual) {
|
||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL);
|
||||
gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL);
|
||||
} else {
|
||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL);
|
||||
gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL);
|
||||
}
|
||||
} else {
|
||||
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE);
|
||||
gl.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE);
|
||||
}
|
||||
curState.shadowCompareMode = texCompareMode;
|
||||
}
|
||||
@ -2340,7 +2395,6 @@ public final class GLRenderer implements Renderer {
|
||||
bindTextureAndUnit(target, img, unit);
|
||||
|
||||
int imageSamples = img.getMultiSamples();
|
||||
|
||||
if (imageSamples <= 1) {
|
||||
if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
|
||||
// Image does not have mipmaps, but they are required.
|
||||
@ -2353,7 +2407,7 @@ public final class GLRenderer implements Renderer {
|
||||
// For OpenGL3 and up.
|
||||
// We'll generate mipmaps via glGenerateMipmapEXT (see below)
|
||||
}
|
||||
} else if (caps.contains(Caps.OpenGL20)) {
|
||||
} else if (caps.contains(Caps.OpenGL20) || caps.contains(Caps.OpenGLES30)) {
|
||||
if (img.hasMipmaps()) {
|
||||
// Image already has mipmaps, set the max level based on the
|
||||
// number of mipmaps we have.
|
||||
@ -3136,6 +3190,7 @@ public final class GLRenderer implements Renderer {
|
||||
public boolean isTaskResultAvailable(int taskId) {
|
||||
return gl.glGetQueryObjectiv(taskId, GL.GL_QUERY_RESULT_AVAILABLE) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAlphaToCoverage() {
|
||||
if (caps.contains(Caps.Multisample)) {
|
||||
|
@ -142,13 +142,13 @@ final class TextureUtil {
|
||||
if (target == GL2.GL_TEXTURE_3D) {
|
||||
// For 3D textures, we upload the entire mipmap level.
|
||||
gl2.glCompressedTexImage3D(target,
|
||||
level,
|
||||
format.internalFormat,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
0,
|
||||
data);
|
||||
level,
|
||||
format.internalFormat,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
0,
|
||||
data);
|
||||
} else if (target == GLExt.GL_TEXTURE_2D_ARRAY_EXT) {
|
||||
// For texture arrays, only upload 1 slice at a time.
|
||||
// zoffset specifies slice index, and depth is 1 to indicate
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.jme3.shader;
|
||||
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.material.ShaderGenerationInfo;
|
||||
import com.jme3.shader.Shader.ShaderType;
|
||||
|
||||
|
||||
/**
|
||||
* This shader Generator can generate Vertex and Fragment shaders from
|
||||
* ShaderNodes for GLESSL 3.0
|
||||
* Nowdays it's just a subclass of Glsl150ShaderGenerator overriding the version
|
||||
* string because GLSL 1.5 is mostly compatible with GLESSL 3.0
|
||||
*
|
||||
* @author Nehon
|
||||
* @author Joliver82
|
||||
*/
|
||||
public class Glsl300ShaderGenerator extends Glsl150ShaderGenerator {
|
||||
|
||||
/**
|
||||
* Creates a Glsl300ShaderGenerator
|
||||
*
|
||||
* @param assetManager the assetmanager
|
||||
*/
|
||||
public Glsl300ShaderGenerator(AssetManager assetManager) {
|
||||
super(assetManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLanguageAndVersion(ShaderType type) {
|
||||
return "GLSL300";
|
||||
}
|
||||
|
||||
}
|
@ -494,6 +494,11 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
||||
* Requires {@link Caps#FloatTexture}.
|
||||
*/
|
||||
RG32F(64,true),
|
||||
|
||||
/**
|
||||
* 10-bit red, green, and blue with 2-bit alpha.
|
||||
*/
|
||||
RGB10A2(32),
|
||||
;
|
||||
|
||||
private int bpp;
|
||||
|
@ -130,6 +130,10 @@ abstract class ImageCodec {
|
||||
0, 11, 6, 1));
|
||||
((BitMaskImageCodec)params.get(Format.RGB5A1)).be = true;
|
||||
|
||||
params.put(Format.RGB10A2, new BitMaskImageCodec(4, 0,
|
||||
2, 10, 10, 10,
|
||||
0, 22, 12, 2));
|
||||
|
||||
// params.put(Format.RGBA8, new ByteAlignedImageCodec(4, 0,
|
||||
// 0, 1, 1, 1,
|
||||
// 0, 0, 1, 2));
|
||||
|
@ -10,8 +10,8 @@ MaterialDef Radial Blur {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL120 GLSL150: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag
|
||||
VertexShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL300 GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
}
|
||||
@ -20,4 +20,4 @@ MaterialDef Radial Blur {
|
||||
RESOLVE_MS : NumSamples
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ MaterialDef Phong Lighting {
|
||||
Technique {
|
||||
LightMode SinglePass
|
||||
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -180,8 +180,8 @@ MaterialDef Phong Lighting {
|
||||
|
||||
LightMode MultiPass
|
||||
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -225,8 +225,8 @@ MaterialDef Phong Lighting {
|
||||
|
||||
Technique PreShadow {
|
||||
|
||||
VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -255,8 +255,8 @@ MaterialDef Phong Lighting {
|
||||
|
||||
|
||||
Technique PostShadow {
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -292,8 +292,8 @@ MaterialDef Phong Lighting {
|
||||
|
||||
Technique PreNormalPass {
|
||||
|
||||
VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -315,8 +315,8 @@ MaterialDef Phong Lighting {
|
||||
|
||||
Technique Glow {
|
||||
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
|
@ -296,7 +296,7 @@ void main(){
|
||||
weight3 /= weightSum;
|
||||
#endif
|
||||
|
||||
#if USE_AMBIENT_LIGHT
|
||||
#ifdef USE_AMBIENT_LIGHT
|
||||
color1.rgb *= g_AmbientLightColor.rgb;
|
||||
color2.rgb *= g_AmbientLightColor.rgb;
|
||||
color3.rgb *= g_AmbientLightColor.rgb;
|
||||
|
@ -123,8 +123,8 @@ MaterialDef PBR Lighting {
|
||||
Technique {
|
||||
LightMode SinglePassAndImageBased
|
||||
|
||||
VertexShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert
|
||||
FragmentShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag
|
||||
VertexShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert
|
||||
FragmentShader GLSL300 GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -167,8 +167,8 @@ MaterialDef PBR Lighting {
|
||||
|
||||
Technique PreShadow {
|
||||
|
||||
VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -197,8 +197,8 @@ MaterialDef PBR Lighting {
|
||||
|
||||
|
||||
Technique PostShadow{
|
||||
VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
|
@ -62,8 +62,8 @@ MaterialDef Unshaded {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -88,8 +88,8 @@ MaterialDef Unshaded {
|
||||
|
||||
Technique PreNormalPass {
|
||||
|
||||
VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -109,8 +109,8 @@ MaterialDef Unshaded {
|
||||
|
||||
Technique PreShadow {
|
||||
|
||||
VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -140,8 +140,8 @@ MaterialDef Unshaded {
|
||||
|
||||
|
||||
Technique PostShadow {
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -176,8 +176,8 @@ MaterialDef Unshaded {
|
||||
|
||||
Technique Glow {
|
||||
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -196,4 +196,4 @@ MaterialDef Unshaded {
|
||||
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ ShaderNodeDefinitions{
|
||||
ShaderNodeDefinition EnvMapping {
|
||||
Type: Fragment
|
||||
|
||||
Shader GLSL300: Common/MatDefs/ShaderNodes/Environment/envMapping130.frag
|
||||
Shader GLSL100: Common/MatDefs/ShaderNodes/Environment/envMapping100.frag
|
||||
Shader GLSL130: Common/MatDefs/ShaderNodes/Environment/envMapping130.frag
|
||||
|
||||
@ -19,4 +20,4 @@ ShaderNodeDefinitions{
|
||||
vec4 color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,17 @@
|
||||
#extension GL_ARB_shader_texture_lod : enable
|
||||
#extension GL_EXT_shader_texture_lod : enable
|
||||
void main(){
|
||||
//@input vec3 refVec the reflection vector
|
||||
//@input samplerCube cubeMap the cube map
|
||||
//@output vec4 color the output color
|
||||
|
||||
color = textureCubeLod(cubeMap, refVec, 0.0);
|
||||
}
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_EXT_shader_texture_lod
|
||||
color = textureCubeLodEXT(cubeMap, refVec, 0.0);
|
||||
#else
|
||||
color = textureCube(cubeMap, refVec);
|
||||
#endif
|
||||
#else
|
||||
color = textureCubeLod(cubeMap, refVec, 0.0);
|
||||
#endif
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ MaterialDef Post Shadow {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -61,4 +61,4 @@ MaterialDef Post Shadow {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ MaterialDef Post Shadow {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150: Common/MatDefs/Shadow/PostShadowFilter.vert
|
||||
FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadowFilter15.frag
|
||||
VertexShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter.vert
|
||||
FragmentShader GLSL310 GLSL150: Common/MatDefs/Shadow/PostShadowFilter15.frag
|
||||
|
||||
WorldParameters {
|
||||
ResolutionInverse
|
||||
@ -88,4 +88,4 @@ MaterialDef Post Shadow {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,18 @@
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
# ifdef GL_ES
|
||||
out highp vec4 outFragColor;
|
||||
# else
|
||||
out vec4 outFragColor;
|
||||
#endif
|
||||
# define texture1D texture
|
||||
# define texture2D texture
|
||||
# define texture3D texture
|
||||
# define textureCube texture
|
||||
# define texture2DLod textureLod
|
||||
# define textureCubeLod textureLod
|
||||
# define texture2DArray texture
|
||||
# if defined VERTEX_SHADER
|
||||
# define varying out
|
||||
# define attribute in
|
||||
@ -33,4 +38,8 @@ out vec4 outFragColor;
|
||||
# define varying in
|
||||
# define gl_FragColor outFragColor
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define isnan(val) !(val<0.0||val>0.0||val==0.0)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ uniform int m_NumSamplesDepth;
|
||||
#endif
|
||||
|
||||
// NOTE: Only define multisample functions if multisample is available
|
||||
#if defined(GL_ARB_texture_multisample)
|
||||
#if defined(GL_ARB_texture_multisample) || (defined GL_ES && __VERSION__>=310)
|
||||
vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){
|
||||
ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
|
||||
vec4 color = vec4(0.0);
|
||||
|
@ -1,16 +1,23 @@
|
||||
#if __VERSION__ >= 130
|
||||
// Because gpu_shader5 is actually where those
|
||||
// gather functions are declared to work on shadowmaps
|
||||
#extension GL_ARB_gpu_shader5 : enable
|
||||
// This "if" statement is useless as jme3 changes line ordering, so all extensions are tried to be loaded
|
||||
#ifdef GL_ES
|
||||
#extension GL_OES_gpu_shader5 : enable
|
||||
#else
|
||||
#extension GL_ARB_gpu_shader5 : enable
|
||||
#endif
|
||||
|
||||
#define IVEC2 ivec2
|
||||
#if defined GL_ES
|
||||
#define SHADOWMAP sampler2D
|
||||
#define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
|
||||
#elif defined HARDWARE_SHADOWS
|
||||
#ifdef HARDWARE_SHADOWS
|
||||
#define SHADOWMAP sampler2DShadow
|
||||
#define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)
|
||||
#define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)
|
||||
#define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)
|
||||
#if defined GL_ES && __VERSION__ <= 300
|
||||
#define SHADOWGATHER(tex,coord) step(coord.z, textureGather(tex, coord.xy))
|
||||
#else
|
||||
#define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)
|
||||
#endif
|
||||
#else
|
||||
#define SHADOWMAP sampler2D
|
||||
#define SHADOWCOMPAREOFFSET(tex,coord,offset) step(coord.z, textureProjOffset(tex, coord, offset).r)
|
||||
@ -31,7 +38,10 @@
|
||||
#endif
|
||||
#else
|
||||
#define IVEC2 vec2
|
||||
#ifdef HARDWARE_SHADOWS
|
||||
#if defined GL_ES
|
||||
#define SHADOWMAP sampler2D
|
||||
#define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
|
||||
#elif defined HARDWARE_SHADOWS
|
||||
#define SHADOWMAP sampler2DShadow
|
||||
#define SHADOWCOMPARE(tex,coord) shadow2DProj(tex, coord).r
|
||||
#else
|
||||
@ -91,10 +101,14 @@ float Shadow_DoShadowCompare(in SHADOWMAP tex,in vec4 projCoord){
|
||||
}
|
||||
|
||||
float Shadow_BorderCheck(in vec2 coord){
|
||||
// Fastest, "hack" method (uses 4-5 instructions)
|
||||
vec4 t = vec4(coord.xy, 0.0, 1.0);
|
||||
t = step(t.wwxy, t.xyzz);
|
||||
return dot(t,t);
|
||||
#ifdef GL_ES
|
||||
return 0.0;
|
||||
#else
|
||||
// Fastest, "hack" method (uses 4-5 instructions)
|
||||
vec4 t = vec4(coord.xy, 0.0, 1.0);
|
||||
t = step(t.wwxy, t.xyzz);
|
||||
return dot(t,t);
|
||||
#endif
|
||||
}
|
||||
|
||||
float Shadow_Nearest(in SHADOWMAP tex,in vec4 projCoord){
|
||||
@ -117,7 +131,8 @@ float Shadow_DoDither_2x2(in SHADOWMAP tex, in vec4 projCoord){
|
||||
return 1.0;
|
||||
|
||||
float shadow = 0.0;
|
||||
IVEC2 o = IVEC2(mod(floor(gl_FragCoord.xy), 2.0));
|
||||
//IVEC2 o = IVEC2(mod(floor(gl_FragCoord.xy), 2.0));
|
||||
vec2 o = vec2(IVEC2(mod(floor(gl_FragCoord.xy), 2.0))); //Strict type checking in GLSL ES
|
||||
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2(-1.5, 1.5)+o));
|
||||
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2( 0.5, 1.5)+o));
|
||||
shadow += Shadow_DoShadowCompareOffset(tex, projCoord, (vec2(-1.5, -0.5)+o));
|
||||
@ -134,7 +149,7 @@ float Shadow_DoBilinear_2x2(in SHADOWMAP tex, in vec4 projCoord){
|
||||
|
||||
vec4 gather = vec4(0.0);
|
||||
#if __VERSION__ >= 130
|
||||
#ifdef GL_ARB_gpu_shader5
|
||||
#if defined GL_ARB_gpu_shader5 || defined GL_OES_gpu_shader5
|
||||
vec4 coord = vec4(projCoord.xyz / projCoord.www,0.0);
|
||||
gather = SHADOWGATHER(tex, coord);
|
||||
#else
|
||||
|
@ -8,10 +8,10 @@ MaterialDef FXAA {
|
||||
Float ReduceMul
|
||||
}
|
||||
Technique {
|
||||
VertexShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert
|
||||
FragmentShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag
|
||||
VertexShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert
|
||||
FragmentShader GLSL300 GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag
|
||||
WorldParameters {
|
||||
ResolutionInverse
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ MaterialDef Light Scattering {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL150 GLSL120: Common/MatDefs/Post/LightScattering.frag
|
||||
VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/LightScattering.frag
|
||||
|
||||
WorldParameters {
|
||||
}
|
||||
@ -26,4 +26,4 @@ MaterialDef Light Scattering {
|
||||
DISPLAY: Display
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ MaterialDef SSAO {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL150 GLSL120: Common/MatDefs/SSAO/ssao.frag
|
||||
VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/SSAO/ssao.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewMatrix
|
||||
@ -34,4 +34,4 @@ MaterialDef SSAO {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,77 +32,77 @@ vec4 convolutionFilter(){
|
||||
float zsum = 1.0;
|
||||
float Zp =readDepth(texCoord);
|
||||
|
||||
vec2 sample = vec2(x - 2.0 * xScale, y - 2.0 * yScale);
|
||||
float zTmp = readDepth(sample);
|
||||
vec2 samplePos = vec2(x - 2.0 * xScale, y - 2.0 * yScale);
|
||||
float zTmp = readDepth(samplePos);
|
||||
float coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 0.0 * xScale, y - 2.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 0.0 * xScale, y - 2.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x + 2.0 * xScale, y - 2.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x + 2.0 * xScale, y - 2.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 1.0 * xScale, y - 1.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 1.0 * xScale, y - 1.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x + 1.0 * xScale, y - 1.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x + 1.0 * xScale, y - 1.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 2.0 * xScale, y - 0.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 2.0 * xScale, y - 0.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x + 2.0 * xScale, y - 0.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x + 2.0 * xScale, y - 0.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 1.0 * xScale, y + 1.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 1.0 * xScale, y + 1.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x + 1.0 * xScale, y + 1.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x + 1.0 * xScale, y + 1.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 2.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 2.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x - 0.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x - 0.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
sample = vec2(x + 2.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(sample);
|
||||
samplePos = vec2(x + 2.0 * xScale, y + 2.0 * yScale);
|
||||
zTmp =readDepth(samplePos);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
zsum += coefZ;
|
||||
sum += coefZ* texture2D( m_SSAOMap, sample);
|
||||
sum += coefZ* texture2D( m_SSAOMap, samplePos);
|
||||
|
||||
|
||||
return sum / zsum;
|
||||
@ -124,4 +124,4 @@ vec4 getColor(vec4 color){
|
||||
|
||||
void main(){
|
||||
gl_FragColor = getColor(convolutionFilter());
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ MaterialDef SSAOBlur {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL150 GLSL120: Common/MatDefs/SSAO/ssaoBlur.frag
|
||||
VertexShader GLSL300 GLSL150 GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL300 GLSL150 GLSL120: Common/MatDefs/SSAO/ssaoBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewMatrix
|
||||
@ -28,4 +28,4 @@ MaterialDef SSAOBlur {
|
||||
RESOLVE_DEPTH_MS : NumSamplesDepth
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -48,9 +48,8 @@ uniform vec3 m_Center;
|
||||
uniform float m_Radius;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 scale = vec2(m_WaveScale, m_WaveScale);
|
||||
float refractionScale = m_WaveScale;
|
||||
vec2 scale; // = vec2(m_WaveScale, m_WaveScale);
|
||||
float refractionScale; // = m_WaveScale;
|
||||
|
||||
// Modifies 4 sampled normals. Increase first values to have more
|
||||
// smaller "waves" or last to have more bigger "waves"
|
||||
@ -62,8 +61,18 @@ const float visibility = 3.0;
|
||||
// foam intensity
|
||||
uniform float m_FoamIntensity ;
|
||||
|
||||
vec2 m_FrustumNearFar; //=vec2(1.0,m_UnderWaterFogDistance);
|
||||
const float LOG2 = 1.442695;
|
||||
|
||||
|
||||
varying vec2 texCoord;
|
||||
|
||||
void setGlobals(){
|
||||
scale = vec2(m_WaveScale, m_WaveScale);
|
||||
refractionScale = m_WaveScale;
|
||||
m_FrustumNearFar=vec2(1.0,m_UnderWaterFogDistance);
|
||||
}
|
||||
|
||||
mat3 MatrixInverse(in mat3 inMatrix){
|
||||
float det = dot(cross(inMatrix[0], inMatrix[1]), inMatrix[2]);
|
||||
mat3 T = transpose(inMatrix);
|
||||
@ -119,9 +128,6 @@ float fresnelTerm(in vec3 normal,in vec3 eyeVec){
|
||||
return saturate(fresnel * (1.0 - saturate(m_R0)) + m_R0 - m_RefractionStrength);
|
||||
}
|
||||
|
||||
vec2 m_FrustumNearFar=vec2(1.0,m_UnderWaterFogDistance);
|
||||
const float LOG2 = 1.442695;
|
||||
|
||||
vec4 underWater(int sampleNum){
|
||||
|
||||
|
||||
@ -225,7 +231,7 @@ vec4 underWater(int sampleNum){
|
||||
#endif
|
||||
|
||||
float fogDepth= (2.0 * m_FrustumNearFar.x) / (m_FrustumNearFar.y + m_FrustumNearFar.x - sceneDepth* (m_FrustumNearFar.y-m_FrustumNearFar.x));
|
||||
float fogIntensity= 18 * m_WaterTransparency;
|
||||
float fogIntensity= 18.0 * m_WaterTransparency;
|
||||
fogFactor = exp2( -fogIntensity * fogIntensity * fogDepth * fogDepth * LOG2 );
|
||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
color =mix(m_DeepWaterColor.rgb,color,fogFactor);
|
||||
@ -284,7 +290,7 @@ vec4 main_multiSample(int sampleNum){
|
||||
samples = 10;
|
||||
#endif
|
||||
|
||||
float biasFactor = 1.0 / samples;
|
||||
float biasFactor = 1.0 / float(samples);
|
||||
for (int i = 0; i < samples; i++){
|
||||
texC = (surfacePoint.xz + eyeVecNorm.xz * biasFactor) * scale + m_Time * 0.03 * m_WindDirection;
|
||||
|
||||
@ -344,7 +350,7 @@ vec4 main_multiSample(int sampleNum){
|
||||
|
||||
normal = normalize(normal0a * normalModifier.x + normal1a * normalModifier.y +normal2a * normalModifier.z + normal3a * normalModifier.w);
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#if __VERSION__ >= 130 && !defined GL_ES
|
||||
// XXX: Here's another way to fix the terrain edge issue,
|
||||
// But it requires GLSL 1.3 and still looks kinda incorrect
|
||||
// around edges
|
||||
@ -435,13 +441,14 @@ vec4 main_multiSample(int sampleNum){
|
||||
}
|
||||
|
||||
void main(){
|
||||
setGlobals();
|
||||
#ifdef RESOLVE_MS
|
||||
vec4 color = vec4(0.0);
|
||||
for (int i = 0; i < m_NumSamples; i++){
|
||||
color += main_multiSample(i);
|
||||
}
|
||||
gl_FragColor = color / m_NumSamples;
|
||||
gl_FragColor = color / float(m_NumSamples);
|
||||
#else
|
||||
gl_FragColor = main_multiSample(0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ MaterialDef Advanced Water {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150 GLSL120 : Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL150 GLSL120: Common/MatDefs/Water/Water.frag
|
||||
VertexShader GLSL310 GLSL300 GLSL150 GLSL120 : Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL310 GLSL300 GLSL150 GLSL120: Common/MatDefs/Water/Water.frag
|
||||
|
||||
WorldParameters {
|
||||
ViewProjectionMatrixInverse
|
||||
@ -72,4 +72,4 @@ MaterialDef Advanced Water {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -128,4 +128,4 @@ public class TestTexture3D extends SimpleApplication {
|
||||
data.add(bb);
|
||||
return new Texture3D(new Image(Format.RGB8, 10, 10, 10, data, null, ColorSpace.Linear));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,4 +84,4 @@ public class TestTextureArray extends SimpleApplication
|
||||
app.start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public class TestTextureArrayCompressed extends SimpleApplication
|
||||
}
|
||||
|
||||
|
||||
Texture tex1 = assetManager.loadTexture( "Textures/Terrain/Pond/Pond.dds");
|
||||
Texture tex2 = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.dds");
|
||||
Texture tex1 = assetManager.loadTexture( "Textures/Terrain/Pond/Pond_dxt5.dds");
|
||||
Texture tex2 = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_dxt5.dds");
|
||||
List<Image> images = new ArrayList<Image>();
|
||||
images.add(tex1.getImage());
|
||||
images.add(tex2.getImage());
|
||||
@ -84,4 +84,4 @@ public class TestTextureArrayCompressed extends SimpleApplication
|
||||
app.start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
#extension GL_EXT_texture_array : enable
|
||||
// #extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
@ -8,7 +10,7 @@ uniform vec4 m_Color;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_COLORMAP
|
||||
#if !defined(GL_EXT_texture_array)
|
||||
#if !defined(GL_EXT_texture_array) && __VERSION__ < 130
|
||||
#error Texture arrays are not supported, but required for this shader.
|
||||
#endif
|
||||
|
||||
@ -54,4 +56,4 @@ void main(){
|
||||
#endif
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ MaterialDef Unshaded {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100: jme3test/texture/UnshadedArray.vert
|
||||
FragmentShader GLSL100: jme3test/texture/UnshadedArray.frag
|
||||
VertexShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.vert
|
||||
FragmentShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -32,8 +32,8 @@ MaterialDef Unshaded {
|
||||
|
||||
Technique PreNormalPass {
|
||||
|
||||
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag
|
||||
VertexShader GLSL300 GLSL100 : Common/MatDefs/SSAO/normal.vert
|
||||
FragmentShader GLSL300 GLSL100 : Common/MatDefs/SSAO/normal.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -50,8 +50,8 @@ MaterialDef Unshaded {
|
||||
|
||||
Technique Glow {
|
||||
|
||||
VertexShader GLSL100: Cjme3test/texture/UnshadedArray.vert
|
||||
FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag
|
||||
VertexShader GLSL300 GLSL100: jme3test/texture/UnshadedArray.vert
|
||||
FragmentShader GLSL300 GLSL100: Common/MatDefs/Light/Glow.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
@ -63,4 +63,4 @@ MaterialDef Unshaded {
|
||||
HAS_COLORMAP // Must be passed so that Unshaded.vert exports texCoord.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
attribute vec3 inPosition;
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform sampler3D m_Texture;
|
||||
|
||||
varying vec3 texCoord;
|
||||
|
||||
void main(){
|
||||
gl_FragColor= texture3D(m_Texture,texCoord);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ MaterialDef My MaterialDef {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100: jme3test/texture/tex3D.vert
|
||||
FragmentShader GLSL100: jme3test/texture/tex3D.frag
|
||||
VertexShader GLSL300 GLSL100: jme3test/texture/tex3D.vert
|
||||
FragmentShader GLSL300 GLSL100: jme3test/texture/tex3D.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
|
||||
attribute vec3 inTexCoord;
|
||||
@ -8,4 +10,4 @@ varying vec3 texCoord;
|
||||
void main(){
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);
|
||||
texCoord=inTexCoord;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform sampler3D m_Texture;
|
||||
uniform int m_Rows;
|
||||
uniform float m_InvDepth;
|
||||
@ -12,4 +14,4 @@ void main(){
|
||||
|
||||
vec3 texC = vec3(fract(texCoord.x),fract(texCoord.y),(depthy * rows + depthx) * m_InvDepth);
|
||||
gl_FragColor = texture3D(m_Texture, texC);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ MaterialDef Tex3DThumb {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100: jme3test/texture/tex3DThumb.vert
|
||||
FragmentShader GLSL100: jme3test/texture/tex3DThumb.frag
|
||||
VertexShader GLSL300 GLSL100: jme3test/texture/tex3DThumb.vert
|
||||
FragmentShader GLSL300 GLSL100: jme3test/texture/tex3DThumb.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
|
||||
attribute vec2 inTexCoord;
|
||||
@ -8,4 +10,4 @@ varying vec2 texCoord;
|
||||
void main(){
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0);
|
||||
texCoord=inTexCoord;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
void main(){
|
||||
gl_FragColor=vec4(1.0,0.0,1.0,0.5);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ const float PI = 3.1415926;
|
||||
void main(){
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
|
||||
float ang = PI * 2.0 / 10.0 * i;
|
||||
vec4 offset = vec4(cos(ang) * 5, -sin(ang) * 5, 0.0, 0.0);
|
||||
float ang = PI * 2.0 / 10.0 * float(i);
|
||||
vec4 offset = vec4(cos(ang) * 5.0, -sin(ang) * 5.0, 0.0, 0.0);
|
||||
gl_Position = g_WorldViewProjectionMatrix*vec4(gl_in[0].gl_Position.xyz + offset.xyz,1.0);
|
||||
|
||||
EmitVertex();
|
||||
|
@ -5,13 +5,13 @@ MaterialDef SimpleGeom {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL330: Materials/Geom/SimpleGeom.vert
|
||||
GeometryShader GLSL330: Materials/Geom/SimpleGeom.geom
|
||||
FragmentShader GLSL330: Materials/Geom/SimpleGeom.frag
|
||||
VertexShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.vert
|
||||
GeometryShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.geom
|
||||
FragmentShader GLSL330 GLSL320: Materials/Geom/SimpleGeom.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
attribute vec3 inPosition;
|
||||
|
||||
void main(){
|
||||
gl_Position=vec4(inPosition,1);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
void main(){
|
||||
gl_FragColor=vec4(1.0,0.0,1.0,0.5);
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ MaterialDef SimpleGeom {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL400: Materials/Tess/SimpleTess.vert
|
||||
TessellationEvaluationShader GLSL400: Materials/Tess/SimpleTess.tseval
|
||||
TessellationControlShader GLSL400: Materials/Tess/SimpleTess.tsctrl
|
||||
FragmentShader GLSL400: Materials/Tess/SimpleTess.frag
|
||||
VertexShader GLSL400 GLSL320: Materials/Tess/SimpleTess.vert
|
||||
TessellationEvaluationShader GLSL400 GLSL320: Materials/Tess/SimpleTess.tseval
|
||||
TessellationControlShader GLSL400 GLSL320: Materials/Tess/SimpleTess.tsctrl
|
||||
FragmentShader GLSL400 GLSL320: Materials/Tess/SimpleTess.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ out gl_PerVertex{
|
||||
uniform int m_TessellationFactor;
|
||||
void main(){
|
||||
if (gl_InvocationID == 0){
|
||||
gl_TessLevelOuter[0]=m_TessellationFactor;
|
||||
gl_TessLevelOuter[1]=m_TessellationFactor;
|
||||
gl_TessLevelOuter[2]=m_TessellationFactor;
|
||||
gl_TessLevelOuter[3]=m_TessellationFactor;
|
||||
float f_TessellationFactor=float(m_TessellationFactor);
|
||||
|
||||
gl_TessLevelInner[0]=m_TessellationFactor;
|
||||
gl_TessLevelInner[1]=m_TessellationFactor;
|
||||
gl_TessLevelOuter[0]=f_TessellationFactor;
|
||||
gl_TessLevelOuter[1]=f_TessellationFactor;
|
||||
gl_TessLevelOuter[2]=f_TessellationFactor;
|
||||
gl_TessLevelOuter[3]=f_TessellationFactor;
|
||||
|
||||
gl_TessLevelInner[0]=f_TessellationFactor;
|
||||
gl_TessLevelInner[1]=f_TessellationFactor;
|
||||
}
|
||||
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ void main(){
|
||||
vec3 p1 = mix(gl_in[1].gl_Position.xyz, gl_in[2].gl_Position.xyz, gl_TessCoord.x);
|
||||
// interpolate in vert direction
|
||||
vec3 tePosition = mix(p0, p1, gl_TessCoord.y);
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(tePosition, 1);
|
||||
gl_Position = g_WorldViewProjectionMatrix * vec4(tePosition, 1.0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
attribute vec3 inPosition;
|
||||
|
||||
void main(){
|
||||
gl_Position=vec4(inPosition,1);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/android.jar
BIN
lib/android.jar
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user