มัลติเท็กซ์เจอร์และป้ายกำกับใน 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);

แต่นี่ไม่ได้แก้ปัญหา

ขอบคุณสำหรับคำตอบ / ความคิดเห็น!

วิธีแก้ไข: ตามคำแนะนำของ Rabbid76 ฉันใช้สิ่งนี้:

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

ผลลัพธ์:

ป้อนคำอธิบายรูปภาพที่นี่


person alexrnov    schedule 24.06.2020    source แหล่งที่มา


คำตอบ (1)


mix สีของ number_texture ด้วยสีขาว แทนที่จะเพิ่มค่าคงที่:

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

จริงๆแล้วมันเหมือนกับ:

outColor = baseColor * (numberColor * 0.5 + 0.5);
person Rabbid76    schedule 24.06.2020