我正在尝试使用libgdx和opengl shader langage从头创建一个神的光线效果。为此,我使用背景图像作为光源,然后将另一个纹理应用为将spriteBatch颜色设置为全黑的掩模。
背景纹理
遮罩纹理
然后在背景上以全黑色呈现面具
Color batchColor = batch.getColor();
fbo1.begin();
batch.begin();
batch.draw(textureBackground, 0, 0, w, h);
batch.setColor(Color.BLACK);
batch.draw(textureBar, 0, 0, w, h);
batch.setColor(batchColor);
batch.end();
fbo1.end();
然后应用了神的光线着色器
Sprite rayEffect = new Sprite(fbo1.getColorBufferTexture());
rayEffect.flip(false, true);
fbo2.begin();
batch.setShader(shaderGodRay);
batch.begin();
rayEffect.draw(batch);
batch.end();
batch.setShader(null);
fbo2.end();
此阶段的光线还可以。知道我想将原始蒙版颜色与渲染光线混合以获得最终图像。仅在光线顶部再次渲染蒙版与彩色蒙版完全重叠
rayEffect = new Sprite(fbo2.getColorBufferTexture());
rayEffect.flip(false, true);
batch.begin();
rayEffect.draw(batch);
batch.draw(textureBar, 0, 0, w, h);
batch.end();
我认为alpha混合应该可以解决问题,但在我的光线渲染图像上,不透明度已满。 有人知道如何将两个纹理混合在一起以获得所需的最终结果吗?