提问者:小点点

Opengl ES 3.0中的多纹理和标签


我想用多重纹理在一个物体上画数字。 但最终的图像更淡,比如:

有没有可能从多纹理中排除白色而使数字颜色更深?

下面是我的片段着色器:

#version 300 es
precision mediump float;
in vec2 v_textureCoord;
out vec4 outColor;
uniform sampler2D base_texture;
uniform sampler2D number_texture;
void main() {
    // wall texture
    vec4 baseColor = texture(base_texture, v_textureCoord);
    // texture with digit
    vec4 numberColor = texture(number_texture, v_textureCoord);
    // resulting pixel color based on two textures 
    outColor = baseColor * (numberColor + 0.5);
}

我试着这么做:

GLES30.glEnable(GLES30.GL_BLEND);
GLES30.glBlendFunc(GLES30.GL_SRC_ALPHA, GLES30.GL_ONE);
GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
...
GLES30.glDisable(GLES30.GL_BLEND);

但这并没有解决问题。

感谢您的任何回答/评论!


共1个答案

匿名用户

用白色混合number_texture的颜色,而不是添加常量:

outColor = baseColor * mix(numberColor, vec4(1.0), 0.5);

实际上,这与:

outColor = baseColor * (numberColor * 0.5 + 0.5);