繁体   English   中英

在FBO中掩盖时背景不可见

[英]Background invisible when masking in an FBO

我试图在LibGDX中将前景纹理蒙版到背景纹理上。 在屏幕上绘制时效果很好,但是在FBO中绘制时,背景消失了。

这是蒙版的绘制方式:

batch.draw(background, x, y);
batch.flush();

Gdx.gl.glColorMask(false, false, false, true);
batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
batch.draw(mask, x, y);
batch.flush();

Gdx.gl.glColorMask(true, true, true, true);
batch.setBlendFunction(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_DST_ALPHA);
batch.draw(foreground, x, y);
batch.flush();

batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

这是我绘制常规图和FBO图的方式:

定期

batch.begin();
batch.enableBlending();
batch.setProjectionMatrix(camera.combined);

drawFull(32, 600 - (64 * 4) - 32);

batch.end();

联邦调查局

// draw the FB mask

fb.begin();
batch.begin();
batch.setProjectionMatrix(fbcamera.combined);
batch.enableBlending();

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

drawFull(0, 0);

batch.end();
fb.end();

// draw the FB mask to the main batch

batch.begin();
batch.enableBlending();
batch.setProjectionMatrix(camera.combined);

batch.draw(fb.getColorBufferTexture(), 32, 600 - (64 * 7) - 32);

batch.end();

我设法通过在将FBO绘制到屏幕时禁用混合来解决此问题。 这样做的缺点是我们不能以不透明的方式绘制FBO。

// draw the FB mask to the main batch

batch.begin();
batch.disableBlending();
batch.setProjectionMatrix(camera.combined);

batch.draw(fb.getColorBufferTexture(), 32, 600 - (64 * 7) - 32);

batch.end();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM