Java Code Examples for com.badlogic.gdx.graphics.glutils.FrameBuffer#getColorBufferTexture()

The following examples show how to use com.badlogic.gdx.graphics.glutils.FrameBuffer#getColorBufferTexture() . 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: Bloom.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void render (final FrameBuffer src, final FrameBuffer dest) {
	Texture texsrc = src.getColorBufferTexture();

	boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND);
	Gdx.gl.glDisable(GL20.GL_BLEND);

	pingPongBuffer.begin();
	{
		// threshold / high-pass filter
		// only areas with pixels >= threshold are blit to smaller fbo
		threshold.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render();

		// blur pass
		blur.render(pingPongBuffer);
	}
	pingPongBuffer.end();

	if (blending || blendingWasEnabled) {
		Gdx.gl.glEnable(GL20.GL_BLEND);
	}

	if (blending) {
		// TODO support for Gdx.gl.glBlendFuncSeparate(sfactor, dfactor, GL20.GL_ONE, GL20.GL_ONE );
		Gdx.gl.glBlendFunc(sfactor, dfactor);
	}

	restoreViewport(dest);

	// mix original scene and blurred threshold, modulate via
	// set(Base|Bloom)(Saturation|Intensity)
	combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render();
}
 
Example 2
Source File: LensFlare2.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void render (final FrameBuffer src, final FrameBuffer dest) {
	Texture texsrc = src.getColorBufferTexture();

	boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND);
	Gdx.gl.glDisable(GL20.GL_BLEND);

	pingPongBuffer.begin();
	{
		// apply bias
		bias.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render();

		lens.setInput(pingPongBuffer.getSourceBuffer()).setOutput(pingPongBuffer.getResultBuffer()).render();

		pingPongBuffer.set(pingPongBuffer.getResultBuffer(), pingPongBuffer.getSourceBuffer());

		// blur pass
		blur.render(pingPongBuffer);
	}
	pingPongBuffer.end();

	if (blending || blendingWasEnabled) {
		Gdx.gl.glEnable(GL20.GL_BLEND);
	}

	if (blending) {
		Gdx.gl.glBlendFunc(sfactor, dfactor);
	}

	restoreViewport(dest);

	// mix original scene and blurred threshold, modulate via
	combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render();
}
 
Example 3
Source File: LightShafts.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
public void render (FrameBuffer src, FrameBuffer dest) {
	Texture tsrc = src.getColorBufferTexture();

	// blur.setPasses(2);

	// 1, render occlusion map
	occlusionMap.begin();
	{
		threshold.setInput(tsrc).setOutput(occlusionMap.getSourceBuffer()).render();
		blur.render(occlusionMap);
	}
	occlusionMap.end();
	// threshold.setInput(tsrc).setOutput(occlusionMap.getResultBuffer()).render(); // threshold without blur

	Texture result = occlusionMap.getResultTexture();

	// 2, render shafts
	occlusionMap.capture();
	{
		shShafts.begin();
		{
			// Gdx.gl.glClearColor(0, 0, 0, 1);
			// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
			result.bind(0);
			shShafts.setUniformi("u_texture", 0);
			quad.render(shShafts);
		}
		shShafts.end();

		// blur pass
		// blur.render(occlusionMap);
	}
	occlusionMap.end();

	restoreViewport(dest);

	// 3, combine
	combine.setOutput(dest).setInput(tsrc, occlusionMap.getResultTexture()).render();
}
 
Example 4
Source File: SlideUpAnimation.java    From Radix with MIT License 5 votes vote down vote up
@Override
public void init() {
    super.init();
    fbo = new FrameBuffer(Pixmap.Format.RGBA4444, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    fboTex = fbo.getColorBufferTexture();
    Gdx.gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL_BLEND);
    SpriteBatch batch = new SpriteBatch();
    batch.setProjectionMatrix(RadixClient.getInstance().getHudCamera().combined);
    fbo.bind();
    batch.begin();
    currentScreen.render(false, batch);
    batch.end();
    FrameBuffer.unbind();
}
 
Example 5
Source File: Bloom.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
@Override
public void render( final FrameBuffer src, final FrameBuffer dest ) {
	Texture texsrc = src.getColorBufferTexture();

	boolean blendingWasEnabled = PostProcessor.isStateEnabled( GL20.GL_BLEND );
	Gdx.gl.glDisable( GL20.GL_BLEND );

	pingPongBuffer.begin();
	{
		// threshold / high-pass filter
		// only areas with pixels >= threshold are blit to smaller fbo
		threshold.setInput( texsrc ).setOutput( pingPongBuffer.getSourceBuffer() ).render();

		// blur pass
		blur.render( pingPongBuffer );
	}
	pingPongBuffer.end();

	if( blending || blendingWasEnabled ) {
		Gdx.gl.glEnable( GL20.GL_BLEND );
	}

	if( blending ) {
		Gdx.gl.glBlendFunc( sfactor, dfactor );
	}

	// mix original scene and blurred threshold, modulate via
	// set(Base|Bloom)(Saturation|Intensity)
	combine.setOutput( dest ).setInput( texsrc, pingPongBuffer.getResultTexture() ).render();
}
 
Example 6
Source File: CrtMonitor.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
@Override
public void render (FrameBuffer src, FrameBuffer dest) {
	// the original scene
	Texture in = src.getColorBufferTexture();

	boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND);
	Gdx.gl.glDisable(GL20.GL_BLEND);

	Texture out = null;

	if (doblur) {

		pingPongBuffer.begin();
		{
			// crt pass
			crt.setInput(in).setOutput(pingPongBuffer.getSourceBuffer()).render();

			// blur pass
			blur.render(pingPongBuffer);
		}
		pingPongBuffer.end();

		out = pingPongBuffer.getResultTexture();
	} else {
		// crt pass
		crt.setInput(in).setOutput(buffer).render();

		out = buffer.getColorBufferTexture();
	}

	if (blending || blendingWasEnabled) {
		Gdx.gl.glEnable(GL20.GL_BLEND);
	}

	if (blending) {
		Gdx.gl.glBlendFunc(sfactor, dfactor);
	}

	restoreViewport(dest);

	// do combine pass
	combine.setOutput(dest).setInput(in, out).render();
}
 
Example 7
Source File: Combine.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public Combine setInput (FrameBuffer buffer1, FrameBuffer buffer2) {
	this.inputTexture = buffer1.getColorBufferTexture();
	this.inputTexture2 = buffer2.getColorBufferTexture();
	return this;
}
 
Example 8
Source File: Ssao.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
@Override
public void render (final FrameBuffer src, final FrameBuffer dest) {
	Texture tsrc = src.getColorBufferTexture();

	Gdx.gl.glDisable(GL20.GL_CULL_FACE);
	Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);

	Camera cam = GameEvents.gameRenderer.camPersp;

	mtxRot.set(cam.view);
	invPrj.set(cam.projection).inv();
	// invRot.set(mtxRot).inv();

	occlusionMap.begin();
	occlusionMap.capture();
	{
		shSsao.begin();
		{
			Gdx.gl.glClearColor(0, 0, 0, 1);
			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

			// samplers
			normalDepthMap.bind(0);
			randomField.bind(1);

			shSsao.setUniformi("normaldepth", 0);
			shSsao.setUniformi("random_field", 1);

			shSsao.setUniformMatrix("proj", cam.projection);
			shSsao.setUniformMatrix("inv_proj", invPrj);
			shSsao.setUniformMatrix("inv_rot", invRot);

			shSsao.setUniformf("viewport", occlusionMap.width, occlusionMap.height);
			shSsao.setUniformf("near", cam.near);
			shSsao.setUniformf("far", cam.far);

			quad.render(shSsao);
		}
		shSsao.end();

		// blur pass
		blur.render(occlusionMap);
	}
	occlusionMap.end();

	restoreViewport(dest);

	if (dest != null) dest.begin();
	shMix.begin();
	{
		tsrc.bind(0);
		occlusionMap.getResultTexture().bind(1);

		shMix.setUniformi("scene", 0);
		shMix.setUniformi("occlusion_map", 1);

		quad.render(shMix);
	}
	shMix.end();
	if (dest != null) dest.end();
}
 
Example 9
Source File: BlockSelectGUI.java    From Radix with MIT License 4 votes vote down vote up
@Override
public void init() {
    render = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    renderTexture = render.getColorBufferTexture();
}
 
Example 10
Source File: CrtMonitor.java    From RuinsOfRevenge with MIT License 4 votes vote down vote up
@Override
public void render( FrameBuffer src, FrameBuffer dest ) {
	// the original scene
	Texture in = src.getColorBufferTexture();

	boolean blendingWasEnabled = PostProcessor.isStateEnabled( GL20.GL_BLEND );
	Gdx.gl.glDisable( GL10.GL_BLEND );

	Texture out = null;

	if( doblur ) {

		pingPongBuffer.begin();
		{
			// crt pass
			crt.setInput( in ).setOutput( pingPongBuffer.getSourceBuffer() ).render();

			// blur pass
			blur.render( pingPongBuffer );
		}
		pingPongBuffer.end();

		out = pingPongBuffer.getResultTexture();
	} else {
		// crt pass
		crt.setInput( in ).setOutput( buffer ).render();

		out = buffer.getColorBufferTexture();
	}

	if( blending || blendingWasEnabled ) {
		Gdx.gl.glEnable( GL20.GL_BLEND );
	}

	if( blending ) {
		Gdx.gl.glBlendFunc( sfactor, dfactor );
	}

	// do combine pass
	combine.setOutput( dest ).setInput( in, out ).render();
}
 
Example 11
Source File: Combine.java    From RuinsOfRevenge with MIT License 4 votes vote down vote up
public Combine setInput( FrameBuffer buffer1, FrameBuffer buffer2 ) {
	this.inputTexture = buffer1.getColorBufferTexture();
	this.inputTexture2 = buffer2.getColorBufferTexture();
	return this;
}