簡體   English   中英

iOs OpenGL ES 2.0與設備和模擬器上的着色器混合

[英]iOs OpenGL ES 2.0 blending with shader on device and on simulator

這是片段着色器代碼的片段(我需要在着色器中進行混合):

float a = texture2D(tMask, texCoords).x; // opacity of current pixel from mask texture.
if ( a == 0.0)
    discard;
else {
    vec4 dst_clr = texture2D(tBkgText, posCoords); // color of current pixel in current framebuffer.
    vec4 src_clr = vec4(vColor.rgb, sOpacity);
    gl_FragColor = src_clr * a + dst_clr * (1.0 - a);
}

這是混合函數和方程式:

glBlendFunc(GL_ONE, GL_ZERO);
glBlendEquation(GL_FUNC_ADD);

這是設備(左)和模擬器(右)的結果:

在設備上在模擬器上

如何使它像在模擬器上一樣工作?

更新:

我已經刪除了discard

float a = texture2D(tMask, texCoords).x; // opacity of current pixel from mask texture.
vec4 dst_clr = texture2D(tBkgText, posCoords); // color of current pixel in current framebuffer.
vec4 src_clr = vec4(vColor.rgb, sOpacity);
gl_FragColor = src_clr * a + dst_clr * (1.0 - a);

現在設備上的結果如下:

在沒有“丟棄”的設備上

我通過在glDrawArrays之后添加glFlush解決了這個問題。 問題在於,當繪圖在其關聯的幀緩沖區中發生時,紋理沒有更新。

暫無
暫無

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

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