public void render(float delta) { time += delta; shaderProgram.begin(); texture.bind(); shaderProgram.setUniformf("tex0", 0); shaderProgram.setUniformf("resolution", Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); shaderProgram.setUniformf("time", time); this.mesh.render(shaderProgram, GL20.GL_TRIANGLE_FAN); shaderProgram.end(); }
private void setSize(int FBO_W, int FBO_H) { w = FBO_W; h = FBO_H; blurShader.begin(); blurShader.setUniformf("size", FBO_W, FBO_H); blurShader.end(); }
private void gaussianBlur() { // cut bright areas of the picture and blit to smaller fbo original.bind(0); pingPongBuffer1.begin(); { tresholdShader.begin(); { // tresholdShader.setUniformi("u_texture0", 0); fullScreenQuad.render(tresholdShader, GL20.GL_TRIANGLE_FAN, 0, 4); } tresholdShader.end(); } pingPongBuffer1.end(); for (int i = 0; i < blurPasses; i++) { pingPongTex1.bind(0); // horizontal pingPongBuffer2.begin(); { blurShader.begin(); { blurShader.setUniformf("dir", 1f, 0f); fullScreenQuad.render(blurShader, GL20.GL_TRIANGLE_FAN, 0, 4); } blurShader.end(); } pingPongBuffer2.end(); pingPongTex2.bind(0); // vertical pingPongBuffer1.begin(); { blurShader.begin(); { blurShader.setUniformf("dir", 0f, 1f); fullScreenQuad.render(blurShader, GL20.GL_TRIANGLE_FAN, 0, 4); } blurShader.end(); } pingPongBuffer1.end(); } }
/** * Treshold for bright parts. everything under treshold is clamped to 0 * * @param treshold must be in range 0..1 */ public void setTreshold(float treshold) { this.treshold = treshold; tresholdShader.begin(); { tresholdShader.setUniformf("treshold", treshold, 1f / (1 - treshold)); } tresholdShader.end(); }
/** * set intensity for original scene. under 1 mean darkening and over 1 means lightening * * @param intensity multiplier for captured texture in combining phase. must be positive. */ public void setOriginalIntesity(float intensity) { originalIntensity = intensity; bloomShader.begin(); { bloomShader.setUniformf("OriginalIntensity", intensity); } bloomShader.end(); }
/** * set intensity for bloom. higher mean more brightening for spots that are over treshold * * @param intensity multiplier for blurred texture in combining phase. must be positive. */ public void setBloomIntesity(float intensity) { bloomIntensity = intensity; bloomShader.begin(); { bloomShader.setUniformf("BloomIntensity", intensity); } bloomShader.end(); }
// vec3 version protected T setParams(Parameter param, Vector3 value) { if (!programBegan) { programBegan = true; program.begin(); } program.setUniformf(param.mnemonic(), value); return (T) this; }
private void initializeShaders() { String vertexShader = "shaders/blur.vert"; String fragmentShader = "shaders/blur.frag"; ShaderProgram.pedantic = false; blurShader = new ShaderProgram(Gdx.files.internal(vertexShader), Gdx.files.internal(fragmentShader)); if (!blurShader.isCompiled()) { System.err.println(blurShader.getLog()); System.exit(0); } if (blurShader.getLog().length() != 0) System.out.println(blurShader.getLog()); blurShader.begin(); blurShader.setUniformf("dir", 0f, 0f); blurShader.setUniformf("resolution", FBO_SIZE); blurShader.setUniformf("radius", blurAmount); blurShader.end(); }
@Override public void draw(Batch batch, float parentAlpha) { batch.setShader(shader); time += Gdx.graphics.getDeltaTime(); if (time > 2 * Math.PI) { time -= 2 * Math.PI; } if (false) { time = 0; magicSize.x = 10000; magicSize.y = 10000; } shader.setUniformf("uInvSize", invSize); shader.setUniformf("uTime", time); shader.setUniformf("u_magicSize", magicSize); batch.draw(bg, IOS8.acceler.getX(), IOS8.acceler.getY()); batch.setShader(null); }
public void render() { Gdx.gl20.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); texture.bind(); shader.begin(); shader.setUniformf("s_texture", 0); Gdx.gl20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER, GL20.GL_NEAREST); shader.setUniformf("u_offset", -0.6f); mesh.render(shader, GL20.GL_TRIANGLES); Gdx.gl20.glTexParameteri( GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER, GL20.GL_LINEAR_MIPMAP_LINEAR); shader.setUniformf("u_offset", 0.6f); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); }
public void render(float delta) { updateOrbs(delta); blurTargetA.begin(); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setShader(null); // resizeBatch(FBO_SIZE, FBO_SIZE); renderOrbs(OrbPart.Light); blurTargetA.end(); blurTargetB.begin(); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1f); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.setShader(blurShader); batch.begin(); blurShader.setUniformf("dir", 1f, 0f); fboRegion.setTexture(blurTargetA.getColorBufferTexture()); batch.draw(fboRegion, 0, 0); batch.flush(); blurTargetB.end(); generateBackground(delta); Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // resizeBatch(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.end(); // renderOrbs(OrbPart.Dark); batch.begin(); blurShader.setUniformf("dir", 0f, 1f); fboRegion.setTexture(blurTargetB.getColorBufferTexture()); batch.draw(fboRegion, 0, 0); batch.setShader(null); batch.end(); }
private void renderWorld(SpriteBatch batch) { worldController.cameraHelper.applyTo(camera); batch.setProjectionMatrix(camera.combined); batch.begin(); if (GamePreferences.instance.useMonochromeShader) { batch.setShader(shaderMonochrome); shaderMonochrome.setUniformf("u_amount", 1.0f); } worldController.level.render(batch); batch.setShader(null); batch.end(); if (DEBUG_DRAW_BOX2D_WORLD) b2debugRenderer.render(worldController.b2world, camera.combined); }
public boolean draw(SpriteBatch batch, ShaderProgram ghostShader, float delta) { // We will use a wibbly-wobbly shader for bill's ghost batch.setShader(ghostShader); ghostTime += delta; ghostShader.setUniformf("time", ghostTime); // ghostShader.setUniformf("resolution", 1.0f, 1.0f); sprite.setPosition(x, y); sprite.setAlpha(alpha); sprite.draw(batch); y += delta * 250; x -= (MathUtils.sin(y / 100 % 360) * 2) * side; alpha = (VIEW_HEIGHT - (y / VIEW_HEIGHT / 2)); batch.setShader(null); // turn off ghost shader. return y <= VIEW_HEIGHT + sprite.getHeight(); }
@Override public void render() { Gdx.gl20.glViewport( 0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); shader.begin(); shader.setUniform2fv( "u_resolution", new float[] {(float) Gdx.graphics.getWidth(), (float) Gdx.graphics.getHeight()}, 0, 2); shader.setUniformf("u_time", TimeUtils.timeSinceMillis(startTime) / 1000f); shader.setUniform2fv( "u_mousePos", new float[] {Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()}, 0, 2); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); }
@Override protected void setShaderUniforms(ShaderProgram shader) { shader.setUniformf("u_h", pickerHue); }
// vec3 protected void setParam(Parameter param, Vector3 value) { program.begin(); program.setUniformf(param.mnemonic(), value); program.end(); }