@Override public TextureDescriptor getDepthMap () { textureDesc.texture = fbo.getColorBufferTexture(); return textureDesc; }
@Override public TextureDescriptor getDepthMap () { textureDesc.texture = fbo.getColorBufferTexture(); return textureDesc; }
public Texture getTexture (int n) { if (n >= getPassQuantity()) throw new GdxRuntimeException("Can't get texture " + n); return frameBuffers[n].getColorBufferTexture(); }
/** Set viewport according to allocator. * @param lp LightProperties to process. * @param cameraViewport Set camera viewport if true. */ protected void processViewport (LightProperties lp, boolean cameraViewport) { Camera camera = lp.camera; ShadowMapRegion r = allocator.nextResult(currentLight); if (r == null) return; TextureRegion region = lp.region; region.setTexture(frameBuffers[currentPass].getColorBufferTexture()); // We don't use HdpiUtils // gl commands related to shadow map size and not to screen size Gdx.gl.glViewport(r.x, r.y, r.width, r.height); Gdx.gl.glScissor(r.x + 1, r.y + 1, r.width - 2, r.height - 2); region.setRegion(r.x, r.y, r.width, r.height); if (cameraViewport) { camera.viewportHeight = r.height; camera.viewportWidth = r.width; camera.update(); } }
m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture()); m_fboRegion.flip(false, true);
spriteBatch.draw(frameBuffer.getColorBufferTexture(), 0, 0, 256, 256, 0, 0, frameBuffer.getColorBufferTexture().getWidth(), frameBuffer.getColorBufferTexture().getHeight(), false, true); spriteBatch.draw(stencilFrameBuffer.getColorBufferTexture(), 256, 256, 256, 256, 0, 0, frameBuffer.getColorBufferTexture() .getWidth(), frameBuffer.getColorBufferTexture().getHeight(), false, true); spriteBatch.end();
public void create () { ShaderProgram.pedantic = false; /* * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal( * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", * "couldn't compile scene shader: " + shader.getLog()); } */ batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal( "data/shaders/convolution.frag").readString()); if (!batchShader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog()); } ObjLoader objLoader = new ObjLoader(); scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj")); sceneInstance = new ModelInstance(scene); modelBatch = new ModelBatch(); fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0, 0, 10); cam.lookAt(0, 0, 0); cam.far = 30; batch = new SpriteBatch(); batch.setShader(batchShader); fboRegion = new TextureRegion(fbo.getColorBufferTexture()); fboRegion.flip(false, true); logger = new FPSLogger(); calculateOffsets(); }
public void render () { Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); fb.begin(); fbshader.begin(); fbshader.setUniformf("u_viewport", fb.getWidth(), fb.getHeight()); fbshader.setUniformf("u_color", 0.0f, 1.0f, 0.0f); quad.render(fbshader, GL20.GL_TRIANGLES); fbshader.end(); fb.end(); ffb.begin(); fbshader.begin(); fbshader.setUniformf("u_viewport", ffb.getWidth(), ffb.getHeight()); fbshader.setUniformf("u_color", 1.0f, 0.0f, 0.0f); quad.render(fbshader, GL20.GL_TRIANGLES); fbshader.end(); ffb.end(); shader.begin(); fb.getColorBufferTexture().bind(0); ffb.getColorBufferTexture().bind(1); shader.setUniformMatrix("u_worldView", screenCamera.combined); shader.setUniformi("u_fbtex", 0); shader.setUniformi("u_ffbtex", 1); screenQuad.render(shader, GL20.GL_TRIANGLES); shader.end(); }
/** * Expert functionality * * @return Texture that contain lightmap texture that can be used as light * texture in your shaders */ public Texture getLightMapTexture() { return lightMap.frameBuffer.getColorBufferTexture(); }
/** * Expert functionality * * @return Texture that contain lightmap texture that can be used as light * texture in your shaders */ public Texture getLightMapTexture() { return lightMap.frameBuffer.getColorBufferTexture(); }
/** When needed graphics memory could be invalidated so buffers should be rebuilt. */ public void rebind () { texture1 = buffer1.getColorBufferTexture(); texture2 = buffer2.getColorBufferTexture(); }
public Combine setInput (FrameBuffer buffer1, FrameBuffer buffer2) { this.inputTexture = buffer1.getColorBufferTexture(); this.inputTexture2 = buffer2.getColorBufferTexture(); return this; }
public Combine setInput (FrameBuffer buffer1, FrameBuffer buffer2) { this.inputTexture = buffer1.getColorBufferTexture(); this.inputTexture2 = buffer2.getColorBufferTexture(); return this; }
/** When needed graphics memory could be invalidated so buffers should be rebuilt. */ public void rebind () { texture1 = buffer1.getColorBufferTexture(); texture2 = buffer2.getColorBufferTexture(); }
@Override public TextureDescriptor getDepthMap () { textureDesc.texture = fbo.getColorBufferTexture(); return textureDesc; }
public T setInput (FrameBuffer input) { return setInput(input.getColorBufferTexture()); }
@Override public void render () { from.getColorBufferTexture().bind(0); to.getColorBufferTexture().bind(1); fade.begin(); fade.setUniformf("Ratio", factor); quad.render(fade); fade.end(); }
@Override public void render () { from.getColorBufferTexture().bind(0); to.getColorBufferTexture().bind(1); fade.begin(); fade.setUniformf("Ratio", factor); quad.render(fade); fade.end(); }
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (fb != null) { batch.draw(fb.getColorBufferTexture(), getX(), getY(), width, height); } }
@Override public void resize(int width, int height) { this.width = width; this.height = height; if (frameBuffer != null) frameBuffer.dispose(); frameBuffer = new FrameBuffer(Pixmap.Format.RGB565, width, height, false); bufferTexture = new TextureRegion(frameBuffer.getColorBufferTexture()); bufferTexture.flip(false, true); }