簡體   English   中英

Opengl ES 3.0 中的多紋理和標簽

[英]Multitexturing and labels in Opengl ES 3.0

我想使用多重紋理在 object 上繪制數字。 但最終的圖像更輕,如:

在此處輸入圖像描述

是否可以從多紋理中排除白色並使數字變暗?

這是我的片段着色器:

#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);

結果:

在此處輸入圖像描述

number_texture的顏色mix為白色,而不是添加常量:

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

實際上,這與以下內容相同:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM