Java Code Examples for com.badlogic.gdx.graphics.glutils.ShaderProgram#isCompiled()
The following examples show how to use
com.badlogic.gdx.graphics.glutils.ShaderProgram#isCompiled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShaderLoader.java From RuinsOfRevenge with MIT License | 6 votes |
public static ShaderProgram fromString( String vertex, String fragment, String vertexName, String fragmentName, String defines ) { ShaderProgram.pedantic = ShaderLoader.Pedantic; ShaderProgram shader = new ShaderProgram( defines + "\n" + vertex, defines + "\n" + fragment ); if( !shader.isCompiled() ) { Gdx.app.error( "ShaderLoader", shader.getLog() ); Gdx.app.exit(); } else { if( defines != null && defines.length() > 0 ) { Gdx.app.log( "ShaderLoader", vertexName + "/" + fragmentName + " compiled w/ (" + defines.replace( "\n", ", " ) + ")" ); } else { Gdx.app.log( "ShaderLoader", vertexName + "/" + fragmentName + " compiled!" ); } } return shader; }
Example 2
Source File: UberShader.java From GdxDemo3D with Apache License 2.0 | 6 votes |
public UberShader(Renderable renderable, Config config) { super(renderable, config); String prefix = DefaultShader.createPrefix(renderable, config); if (renderable.material.has(VertexColorTextureBlend.Red)) { prefix += "#define redVertexColorBlendFlag\n"; } if (renderable.material.has(VertexColorTextureBlend.Green)) { prefix += "#define greenVertexColorBlendFlag\n"; } if (renderable.material.has(VertexColorTextureBlend.Blue)) { prefix += "#define blueVertexColorBlendFlag\n"; } program = new ShaderProgram(prefix + config.vertexShader, prefix + config.fragmentShader); if (!program.isCompiled()) { Gdx.app.debug(TAG, program.getLog()); } }
Example 3
Source File: ShaderUtils.java From Mundus with Apache License 2.0 | 6 votes |
/** * Compiles and links shader. * * @param vertexShader * path to vertex shader * @param fragmentShader * path to fragment shader * * @return compiled shader program */ public static ShaderProgram compile(String vertexShader, String fragmentShader) { String vert; String frag; if (Gdx.app.getType() == Application.ApplicationType.WebGL) { vert = Gdx.files.internal(vertexShader).readString(); frag = Gdx.files.internal(fragmentShader).readString(); } else { vert = Gdx.files.classpath(vertexShader).readString(); frag = Gdx.files.classpath(fragmentShader).readString(); } ShaderProgram program = new ShaderProgram(vert, frag); if (!program.isCompiled()) { throw new GdxRuntimeException(program.getLog()); } return program; }
Example 4
Source File: GameScreen.java From TerraLegion with MIT License | 6 votes |
@Override public void create() { //Load UI gameHud = new GameHud(this, world); ShaderProgram.pedantic = false; program = new ShaderProgram(Gdx.files.internal("shaders/sepia.vsh"), Gdx.files.internal("shaders/sepia.fsh")); if (!program.isCompiled()) { System.out.println(program.getLog()); } camera = new OrthoCamera(); Timer.startGameTime(); resize(Settings.getWidth(), Settings.getHeight()); }
Example 5
Source File: IBLBuilder.java From gdx-gltf with Apache License 2.0 | 5 votes |
private IBLBuilder() { shapes = new ShapeRenderer(20); shapes.getProjectionMatrix().setToOrtho2D(0, 0, 1, 1); sunShader = new ShaderProgram( Gdx.files.classpath("net/mgsx/gltf/shaders/ibl-sun.vs.glsl"), Gdx.files.classpath("net/mgsx/gltf/shaders/ibl-sun.fs.glsl")); if(!sunShader.isCompiled()) throw new GdxRuntimeException(sunShader.getLog()); sunShapes = new ShapeRenderer(20, sunShader); sunShapes.getProjectionMatrix().setToOrtho2D(0, 0, 1, 1); }
Example 6
Source File: FluidSimulatorSPH.java From fluid-simulator-v2 with Apache License 2.0 | 5 votes |
private void createWorld() { dropRadius = 0.1f + dropRadiusK; dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE); dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel; if (IS_DESKTOP) { // dropTexture = new Texture("data/fluid_drop_red_64.png"); dropTexture = new Texture("data/fluid_drop_64.png"); dropTexture2 = new Texture("data/fluid_drop_blue_64.png"); dropSprite = new Sprite(dropTexture); dropSprite.setSize(dropRadiusPixel, dropRadiusPixel); } if (IS_DESKTOP) { disposableParticles = new ArrayList<Particle>(SIZE); } defaultShader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal("data/shaders/default.frag").readString()); if (!defaultShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile scene shader: " + defaultShader.getLog()); } immediateRenderer = new ImmediateModeRenderer20(50000, false, true, 0); // On Android populate directly if (!IS_DESKTOP) { for (float j = INITIAL_HEIGHT + hpadding + 2; j < WORLD_HEIGHT - 2; j += 1.0f) { for (float i = -WORLD_WIDTH / 3; i < WORLD_WIDTH / 3; i += 1.0f) { particles.add(new Particle(i, j)); tempParticle = particles.get(particles.size() - 1); tempParticle.type = (emitType); if (particles.size() >= ANDROID_SIZE) return; } } } }
Example 7
Source File: PickerCommons.java From vis-ui with Apache License 2.0 | 5 votes |
private ShaderProgram loadShader (String vertFile, String fragFile) { ShaderProgram program = new ShaderProgram( Gdx.files.classpath("com/kotcrab/vis/ui/widget/color/internal/" + vertFile), Gdx.files.classpath("com/kotcrab/vis/ui/widget/color/internal/" + fragFile)); if (program.isCompiled() == false) { throw new IllegalStateException("ColorPicker shader compilation failed. Shader: " + vertFile + ", " + fragFile + ": " + program.getLog()); } return program; }
Example 8
Source File: EditorTerrainShader.java From Mundus with Apache License 2.0 | 5 votes |
public EditorTerrainShader() { String vertexShader = "\n#define PICKER\n" + Gdx.files.classpath(VERTEX_SHADER).readString(); String fragmentShader = "\n#define PICKER\n" + Gdx.files.classpath(FRAGMENT_SHADER).readString(); program = new ShaderProgram(vertexShader, fragmentShader); if (!program.isCompiled()) { throw new GdxRuntimeException(program.getLog()); } }
Example 9
Source File: ShaderManager.java From beatoraja with GNU General Public License v3.0 | 5 votes |
public static ShaderProgram getShader(String name) { if (!shaders.containsKey(name)) { ShaderProgram shader = new ShaderProgram(Gdx.files.classpath("glsl/" + name + ".vert"), Gdx.files.classpath("glsl/" + name + ".frag")); if(shader.isCompiled()) { shaders.put(name, shader); return shader; } } return shaders.get(name); }
Example 10
Source File: Shader.java From seventh with GNU General Public License v2.0 | 5 votes |
/** * Reloads the shader from disk */ public void reload() { shader = new ShaderProgram(Gdx.files.internal(vert), Gdx.files.internal(frag)); if (!shader.isCompiled()) { Cons.println("Unable to compile shaders: " + vert + " : " + frag); } // Good idea to log any warnings if they exist if (shader.getLog().length() != 0) { Cons.println(shader.getLog()); } }
Example 11
Source File: ShadowShader.java From uracer-kotd with Apache License 2.0 | 5 votes |
static final public ShaderProgram createShadowShader() { final String vertexShader = "attribute vec4 a_position;\n" // + "attribute vec2 a_texCoord;\n" // + "varying vec2 v_texCoords;\n" // + "\n" // + "void main()\n" // + "{\n" // + " v_texCoords = a_texCoord;\n" // + " gl_Position = a_position;\n" // + "}\n"; final String fragmentShader = "#ifdef GL_ES\n" // + "#define MED " + RayHandler.getColorPrecision() + "\n" + "precision " + RayHandler.getColorPrecision() + " float;\n" // + "#else\n" + "#define MED \n" + "#endif\n" // + "varying vec2 v_texCoords;\n" // + "uniform MED sampler2D u_texture;\n" // + "uniform MED vec4 ambient;\n" + "void main()\n"// + "{\n" // + "vec4 v_c = texture2D(u_texture, v_texCoords);\n" + "v_c.rgb = ambient.rgb + v_c.rgb* v_c.a;\n"// + "v_c.a = ambient.a - v_c.a;\n"// + "gl_FragColor = v_c;\n"// + "}\n"; ShaderProgram.pedantic = false; ShaderProgram shadowShader = new ShaderProgram( vertexShader, fragmentShader ); if( shadowShader.isCompiled() == false ) { Gdx.app.log( "ERROR", shadowShader.getLog() ); } return shadowShader; }
Example 12
Source File: DiffuseShader.java From uracer-kotd with Apache License 2.0 | 5 votes |
static final public ShaderProgram createShadowShader() { final String vertexShader = "attribute vec4 a_position;\n" // + "attribute vec2 a_texCoord;\n" // + "varying vec2 v_texCoords;\n" // + "\n" // + "void main()\n" // + "{\n" // + " v_texCoords = a_texCoord;\n" // + " gl_Position = a_position;\n" // + "}\n"; // this is allways perfect precision final String fragmentShader = "#ifdef GL_ES\n" // + "precision mediump float;\n" // + "#endif\n" // + "varying vec2 v_texCoords;\n" // + "uniform sampler2D u_texture;\n" // + "uniform vec4 ambient;\n" + "void main()\n"// + "{\n" // + "gl_FragColor = ambient + texture2D(u_texture, v_texCoords);\n" + "}\n"; ShaderProgram.pedantic = false; ShaderProgram shadowShader = new ShaderProgram(vertexShader, fragmentShader); if (shadowShader.isCompiled() == false) { Gdx.app.log("ERROR", shadowShader.getLog()); } return shadowShader; }
Example 13
Source File: ShaderLoader.java From uracer-kotd with Apache License 2.0 | 5 votes |
public static ShaderProgram fromString( String vertex, String fragment, String vertexName, String fragmentName, String defines ) { ShaderProgram.pedantic = ShaderLoader.Pedantic; ShaderProgram shader = new ShaderProgram( defines + "\n" + vertex, defines + "\n" + fragment ); if( !shader.isCompiled() ) { Gdx.app.error( "ShaderLoader", shader.getLog() ); System.exit( -1 ); } return shader; }
Example 14
Source File: VfxGLUtils.java From gdx-vfx with Apache License 2.0 | 5 votes |
public static ShaderProgram compileShader(FileHandle vertexFile, FileHandle fragmentFile, String defines) { if (fragmentFile == null) { throw new IllegalArgumentException("Vertex shader file cannot be null."); } if (vertexFile == null) { throw new IllegalArgumentException("Fragment shader file cannot be null."); } if (defines == null) { throw new IllegalArgumentException("Defines cannot be null."); } StringBuilder sb = new StringBuilder(); sb.append("Compiling \"").append(vertexFile.name()).append('/').append(fragmentFile.name()).append('\"'); if (defines.length() > 0) { sb.append(" w/ (").append(defines.replace("\n", ", ")).append(")"); } sb.append("..."); Gdx.app.log(TAG, sb.toString()); String prependVert = prependVertexCode + defines; String prependFrag = prependFragmentCode + defines; String srcVert = vertexFile.readString(); String srcFrag = fragmentFile.readString(); ShaderProgram shader = new ShaderProgram(prependVert + "\n" + srcVert, prependFrag + "\n" + srcFrag); if (!shader.isCompiled()) { throw new GdxRuntimeException("Shader compile error: " + vertexFile.name() + "/" + fragmentFile.name() + "\n" + shader.getLog()); } return shader; }
Example 15
Source File: Gaussian.java From uracer-kotd with Apache License 2.0 | 4 votes |
public static ShaderProgram createBlurShader(int width, int heigth) { final String FBO_W = Integer.toString(width); final String FBO_H = Integer.toString(heigth); final String vertexShader = "attribute vec4 a_position;\n" // + "uniform vec2 dir;\n" // + "attribute vec2 a_texCoord;\n" // + "varying vec2 v_texCoords0;\n" // + "varying vec2 v_texCoords1;\n" // + "varying vec2 v_texCoords2;\n" // + "varying vec2 v_texCoords3;\n" // + "varying vec2 v_texCoords4;\n" // + "#define FBO_W " + FBO_W + ".0\n"// + "#define FBO_H " + FBO_H + ".0\n"// + "const vec2 futher = vec2(3.2307692308 / FBO_W, 3.2307692308 / FBO_H );\n" // + "const vec2 closer = vec2(1.3846153846 / FBO_W, 1.3846153846 / FBO_H );\n" // + "void main()\n" // + "{\n" // + "vec2 f = futher * dir;\n" // + "vec2 c = closer * dir;\n" // + "v_texCoords0 = a_texCoord - f;\n" // + "v_texCoords1 = a_texCoord - c;\n" // + "v_texCoords2 = a_texCoord;\n" // + "v_texCoords3 = a_texCoord + c;\n" // + "v_texCoords4 = a_texCoord + f;\n" // + "gl_Position = a_position;\n" // + "}\n"; final String fragmentShader = "#ifdef GL_ES\n" // + "#define MED " + RayHandler.getColorPrecision() + "\n" + "precision " + RayHandler.getColorPrecision() + " float;\n" // + "#else\n"// + "#define MED \n"// + "#endif\n" // + "uniform MED sampler2D u_texture;\n" // + "varying vec2 v_texCoords0;\n" // + "varying vec2 v_texCoords1;\n" // + "varying vec2 v_texCoords2;\n" // + "varying vec2 v_texCoords3;\n" // + "varying vec2 v_texCoords4;\n" // + "const float center = 0.2270270270;\n" // + "const float close = 0.3162162162;\n" // + "const float far = 0.0702702703;\n" // + "void main()\n" // + "{ \n" // + "gl_FragColor = far * texture2D(u_texture, v_texCoords0)\n" // + " + close * texture2D(u_texture, v_texCoords1)\n" // + " + center * texture2D(u_texture, v_texCoords2)\n" // + " + close * texture2D(u_texture, v_texCoords3)\n" // + " + far * texture2D(u_texture, v_texCoords4);\n"// + "}\n"; ShaderProgram.pedantic = false; ShaderProgram blurShader = new ShaderProgram(vertexShader, fragmentShader); if (blurShader.isCompiled() == false) { Gdx.app.log("ERROR", blurShader.getLog()); } return blurShader; }
Example 16
Source File: LightShader.java From uracer-kotd with Apache License 2.0 | 4 votes |
static final public ShaderProgram createLightShader() { String gamma = ""; if (RayHandler.getGammaCorrection()) gamma = "sqrt"; final String vertexShader = "#ifdef GL_ES\n" // + "#define MED "+ RayHandler.getColorPrecision() + "\n" + "precision "+RayHandler.getColorPrecision()+" float;\n" // + "#define PRES mediump\n" + "#else\n" + "#define MED \n" + "#define PRES \n" + "#endif\n" // + "attribute MED vec4 vertex_positions;\n" // + "attribute MED vec4 quad_colors;\n" // + "attribute float s;\n" + "uniform PRES mat4 u_projTrans;\n" // + "varying MED vec4 v_color;\n" // + "void main()\n" // + "{\n" // + " v_color = s * quad_colors;\n" // + " gl_Position = u_projTrans * vertex_positions;\n" // + "}\n"; final String fragmentShader = "#ifdef GL_ES\n" // + "#define MED "+ RayHandler.getColorPrecision() + "\n" + "precision "+RayHandler.getColorPrecision()+" float;\n" // + "#else\n" + "#define MED \n" + "#endif\n" // + "varying MED vec4 v_color;\n" // + "void main()\n"// + "{\n" // + " gl_FragColor = "+gamma+"(v_color);\n" // + "}"; ShaderProgram.pedantic = false; ShaderProgram lightShader = new ShaderProgram(vertexShader, fragmentShader); if (lightShader.isCompiled() == false) { Gdx.app.log("ERROR", lightShader.getLog()); } return lightShader; }
Example 17
Source File: Box2dLightCustomShaderTest.java From box2dlights with Apache License 2.0 | 4 votes |
private ShaderProgram createLightShader () { // Shader adapted from https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson6 final String vertexShader = "attribute vec4 vertex_positions;\n" // + "attribute vec4 quad_colors;\n" // + "attribute float s;\n" + "uniform mat4 u_projTrans;\n" // + "varying vec4 v_color;\n" // + "void main()\n" // + "{\n" // + " v_color = s * quad_colors;\n" // + " gl_Position = u_projTrans * vertex_positions;\n" // + "}\n"; final String fragmentShader = "#ifdef GL_ES\n" // + "precision lowp float;\n" // + "#define MED mediump\n" + "#else\n" + "#define MED \n" + "#endif\n" // + "varying vec4 v_color;\n" // + "uniform sampler2D u_normals;\n" // + "uniform vec3 u_lightpos;\n" // + "uniform vec2 u_resolution;\n" // + "uniform float u_intensity = 1.0;\n" // + "void main()\n"// + "{\n" + " vec2 screenPos = gl_FragCoord.xy / u_resolution.xy;\n" + " vec3 NormalMap = texture2D(u_normals, screenPos).rgb; " + " vec3 LightDir = vec3(u_lightpos.xy - screenPos, u_lightpos.z);\n" + " vec3 N = normalize(NormalMap * 2.0 - 1.0);\n" + " vec3 L = normalize(LightDir);\n" + " float maxProd = max(dot(N, L), 0.0);\n" + "" // + " gl_FragColor = v_color * maxProd * u_intensity;\n" // + "}"; ShaderProgram.pedantic = false; ShaderProgram lightShader = new ShaderProgram(vertexShader, fragmentShader); if (!lightShader.isCompiled()) { Gdx.app.log("ERROR", lightShader.getLog()); } lightShader.begin(); lightShader.setUniformi("u_normals", 1); lightShader.setUniformf("u_resolution", Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); lightShader.end(); return lightShader; }
Example 18
Source File: Box2dLightCustomShaderTest.java From box2dlights with Apache License 2.0 | 4 votes |
private ShaderProgram createNormalShader () { String vertexShader = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + "attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + "uniform mat4 u_projTrans;\n" // + "uniform float u_rot;\n" // + "varying vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "varying mat2 v_rot;\n" // + "\n" // + "void main()\n" // + "{\n" // + " vec2 rad = vec2(-sin(u_rot), cos(u_rot));\n" // + " v_rot = mat2(rad.y, -rad.x, rad.x, rad.y);\n" // + " v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + " v_color.a = v_color.a * (255.0/254.0);\n" // + " v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "}\n"; String fragmentShader = "#ifdef GL_ES\n" // + "#define LOWP lowp\n" // + "precision mediump float;\n" // + "#else\n" // + "#define LOWP \n" // + "#endif\n" // + "varying LOWP vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "varying mat2 v_rot;\n" // + "uniform sampler2D u_texture;\n" // + "void main()\n"// + "{\n" // + " vec4 normal = texture2D(u_texture, v_texCoords).rgba;\n" // // got to translate normal vector to -1, 1 range + " vec2 rotated = v_rot * (normal.xy * 2.0 - 1.0);\n" // // and back to 0, 1 + " rotated = (rotated.xy / 2.0 + 0.5 );\n" // + " gl_FragColor = vec4(rotated.xy, normal.z, normal.a);\n" // + "}"; ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader); if (!shader.isCompiled()) throw new IllegalArgumentException("Error compiling shader: " + shader.getLog()); return shader; }
Example 19
Source File: FluidSimulatorLiquid.java From fluid-simulator-v2 with Apache License 2.0 | 4 votes |
private void createWorld() { dropRadius = 0.1f + dropRadiusK; dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE); dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel; dropTexture = new Texture("data/fluid_drop_64.png"); dropTexture2 = new Texture("data/fluid_drop_64.png"); dropSprite = new Sprite(dropTexture); dropSprite.setSize(dropRadiusPixel, dropRadiusPixel); if (IS_DESKTOP) { disposableParticles = new ArrayList<Particle>(SIZE); } defaultShader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal("data/shaders/default.frag").readString()); if (!defaultShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile default shader: " + defaultShader.getLog()); } defaultIMShader = new ShaderProgram(Gdx.files.internal("data/shaders/defaultim.vert").readString(), Gdx.files.internal("data/shaders/defaultim.frag").readString()); if (!defaultIMShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile default IM shader: " + defaultIMShader.getLog()); } ShaderProgram.pedantic = false; refractionShader = new ShaderProgram(Gdx.files.internal("data/shaders/refract.vert").readString(), Gdx.files.internal("data/shaders/refract.frag").readString()); if (!refractionShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile refraction shader: " + refractionShader.getLog()); } irt.setShader(defaultIMShader); bgTexture = new Texture("data/bg.png"); glossMapTexture = new Texture("data/gloss_map2.png"); displacementMap = new Texture("data/water1.png"); displacementMap2 = new Texture("data/water2.png"); bgSprite = new Sprite(bgTexture); bgSprite.setBounds(0, -1, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() + 1); // On Android populate directly if (!IS_DESKTOP) { for (float j = INITIAL_HEIGHT + hpadding + 2; j < BOX_HEIGHT - 2; j += 5.5f) { for (float i = -BOX_WIDTH / 3; i < BOX_WIDTH / 3; i += 5.5f) { particles.add(new Particle(i, j, prevHash++)); tempParticle = particles.get(particles.size() - 1); tempParticle.type = (emitType); if (particles.size() >= ANDROID_SIZE) break; } if (particles.size() >= ANDROID_SIZE) break; } } // createPiece(17, 0, 150, 0, 0, 0, false, true, true); createPiece(17, 100, 240, 0, 0, 0, false, true, true); // Boxes createPiece(6, 0, 160, 0, 0, 0, false, false, true); createPiece(14, -150, 200, 0, 0, 0, false, false, true); createPiece(14, 0, 140, 0, 0, 0, false, false, true); createPiece(14, -170, 60, 90, 0, 0, false, false, true); // Ball createPiece(4, 100, 100, 0, -20, 0, false, false, true); // Portals createPortalIn(-140, 65, 0, 0); createPortalOut(-140, 240, 0, 0); // Ground cage createPiece(18, -BOX_WIDTH/2 + 7, BOX_HEIGHT/2, 0, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, BOX_WIDTH/2 - 10, BOX_HEIGHT/2, 0, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, 0, INITIAL_HEIGHT, 90, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, 0, BOX_HEIGHT - 10, 90, 0, 0, 0.2f, 0.5f, false, false, true); // Ground body for mousejoint BodyDef bodyDef = new BodyDef(); // bodyDef.type = BodyType.StaticBody; groundBody = world.createBody(bodyDef); }
Example 20
Source File: FluidSimulatorMPM.java From fluid-simulator-v2 with Apache License 2.0 | 4 votes |
private void createWorld() { dropRadius = 0.1f + dropRadiusK; dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE); dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel; dropTexture = new Texture("data/fluid_drop_64.png"); dropTexture2 = new Texture("data/fluid_drop_64.png"); dropSprite = new Sprite(dropTexture); dropSprite.setSize(dropRadiusPixel, dropRadiusPixel); if (IS_DESKTOP) { disposableParticles = new ArrayList<Particle>(SIZE); } defaultShader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal("data/shaders/default.frag").readString()); if (!defaultShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile default shader: " + defaultShader.getLog()); } defaultIMShader = new ShaderProgram(Gdx.files.internal("data/shaders/defaultim.vert").readString(), Gdx.files.internal("data/shaders/defaultim.frag").readString()); if (!defaultIMShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile default IM shader: " + defaultIMShader.getLog()); } ShaderProgram.pedantic = false; refractionShader = new ShaderProgram(Gdx.files.internal("data/shaders/refract.vert").readString(), Gdx.files.internal("data/shaders/refract.frag").readString()); if (!refractionShader.isCompiled()) { Gdx.app.log("SHADER_LOG", "couldn't compile refraction shader: " + refractionShader.getLog()); } irt.setShader(defaultIMShader); bgTexture = new Texture("data/bg.png"); glossMapTexture = new Texture("data/gloss_map2.png"); displacementMap = new Texture("data/water1.png"); displacementMap2 = new Texture("data/water2.png"); bgSprite = new Sprite(bgTexture); bgSprite.setBounds(0, -1, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() + 1); // createPiece(17, 0, 150, 0, 0, 0, false, true, true); createPiece(17, 100, 240, 0, 0, 0, false, true, true); // createPortalIn(-140, 65, 0, 0, false, true); // createPortalOut(-140, 220, 0, 0, false, true); // Boxes createPiece(6, 0, 160, 0, 0, 0, false, false, true); createPiece(14, -150, 200, 0, 0, 0, false, false, true); createPiece(14, 0, 140, 0, 0, 0, false, false, true); createPiece(14, -170, 60, 90, 0, 0, false, false, true); // Ball createPiece(4, 100, 100, 0, -20, 0, false, false, true); // Ground cage createPiece(18, -BOX_WIDTH/2 + 7, BOX_HEIGHT/2, 0, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, BOX_WIDTH/2 - 10, BOX_HEIGHT/2, 0, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, 0, INITIAL_HEIGHT, 90, 0, 0, 0.2f, 0.5f, false, false, true); createPiece(18, 0, BOX_HEIGHT - 10, 90, 0, 0, 0.2f, 0.5f, false, false, true); // Ground body for mousejoint BodyDef bodyDef = new BodyDef(); // bodyDef.type = BodyType.StaticBody; groundBody = world.createBody(bodyDef); }