Fixes post shadows compilation issue on android
This commit is contained in:
parent
c72b73ee8b
commit
6b2af9917b
@ -1327,6 +1327,7 @@ public final class GLRenderer implements Renderer {
|
|||||||
+ "Only GLSL 1.00 shaders are supported.");
|
+ "Only GLSL 1.00 shaders are supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean insertPrecision = false;
|
||||||
// Upload shader source.
|
// Upload shader source.
|
||||||
// Merge the defines and source code.
|
// Merge the defines and source code.
|
||||||
stringBuf.setLength(0);
|
stringBuf.setLength(0);
|
||||||
@ -1346,7 +1347,7 @@ public final class GLRenderer implements Renderer {
|
|||||||
|
|
||||||
if (source.getType() == ShaderType.Fragment) {
|
if (source.getType() == ShaderType.Fragment) {
|
||||||
// GLES2 requires precision qualifier.
|
// GLES2 requires precision qualifier.
|
||||||
stringBuf.append("precision mediump float;\n");
|
insertPrecision = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// version 100 does not exist in desktop GLSL.
|
// version 100 does not exist in desktop GLSL.
|
||||||
@ -1365,6 +1366,14 @@ public final class GLRenderer implements Renderer {
|
|||||||
stringBuf.append(source.getDefines());
|
stringBuf.append(source.getDefines());
|
||||||
stringBuf.append(source.getSource());
|
stringBuf.append(source.getSource());
|
||||||
|
|
||||||
|
if(insertPrecision){
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
intBuf1.clear();
|
intBuf1.clear();
|
||||||
intBuf1.put(0, stringBuf.length());
|
intBuf1.put(0, stringBuf.length());
|
||||||
gl.glShaderSource(id, new String[]{ stringBuf.toString() }, intBuf1);
|
gl.glShaderSource(id, new String[]{ stringBuf.toString() }, intBuf1);
|
||||||
|
|||||||
@ -3,7 +3,10 @@
|
|||||||
// gather functions are declared to work on shadowmaps
|
// gather functions are declared to work on shadowmaps
|
||||||
#extension GL_ARB_gpu_shader5 : enable
|
#extension GL_ARB_gpu_shader5 : enable
|
||||||
#define IVEC2 ivec2
|
#define IVEC2 ivec2
|
||||||
#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 SHADOWMAP sampler2DShadow
|
||||||
#define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)
|
#define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)
|
||||||
#define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)
|
#define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)
|
||||||
|
|||||||
@ -69,7 +69,6 @@ public class TestShadowsPerf extends SimpleApplication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
Logger.getLogger("com.jme3").setLevel(Level.SEVERE);
|
|
||||||
flyCam.setMoveSpeed(50);
|
flyCam.setMoveSpeed(50);
|
||||||
flyCam.setEnabled(false);
|
flyCam.setEnabled(false);
|
||||||
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
|
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user