1
libGDX FrameBuffer 및 Alpha에 문제가 있습니다. 아래는 예상 결과와 실제 결과의 두 이미지입니다. 누군가 내가 뭘 잘못하고 어떻게 해결할 수 있는지 말해 줄 수 있습니까?libGDX 프레임 버퍼 알파 문제
FrameBuffer buffer;
Sprite sprite;
SpriteBatch batch;
Texture texture1;
Texture texture2;
Texture texture3;
Sprite texture2Sprite;
@Override
public void create() {
batch = new SpriteBatch();
texture1 = new Texture("1.png");
texture2 = new Texture("2.png");
texture3 = new Texture("3.png");
texture2Sprite = new Sprite(texture2);
texture2Sprite.setAlpha(0.5f);
texture2Sprite.setPosition(100, 100);
buffer = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
sprite = new Sprite(buffer.getColorBufferTexture());
sprite.flip(false, true);
}
public void createFBO()
{
buffer.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(texture1, 0f, 0f);
texture2Sprite.draw(batch);
batch.end();
buffer.end();
}
@Override
public void render() {
createFBO();
Gdx.gl.glClearColor(0f, 0f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.enableBlending();
batch.draw(texture3, 200, 200);
sprite.draw(batch);
batch.end();
}
안녕하세요, 덕분에 완벽하게 작동했습니다 ... 그러나 한 가지 더 후속 조치가 있습니다. 알파 컴포넌트가있는 FrameBuffer에 무언가를 그리기를 원하지만 또 다른 쉐이더 프로그램을 사용한다고 가정 해 보겠습니다. 나는 어떻게 그것에 대해 갈 것인가? – user5207217
그것은 당신을 위해 일했기 때문에 다행. 다음 호의 주위에있는 유일한 방법은 다른 커스텀 쉐이더의 또 다른 버전을 만들어 미리 곱한 알파를 그리는 것입니다. 대부분의 쉐이더를 상상해보십시오. 마지막에 필요한 라인을 간단하게 추가 할 수 있습니다. 'gl_FragColor.rgb * = gl_FragColor.a;' – hamham