Note that there are some explanatory texts on larger screens.

plurals
  1. POiOs OpenGL ES 2.0 adding textures with low opacity on device and on simulator
    primarykey
    data
    text
    <p>I have a problem with multiple drawing of textures in my program.</p> <p>Blending mode is</p> <pre><code>glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); </code></pre> <p>The value of a-channel is passed into the shader from cpu-code.</p> <pre><code>precision highp float; uniform sampler2D tShape; uniform vec4 vColor; uniform float sOpacity; varying vec4 texCoords;\n" void main() { float a = texture2D(tShape, texCoords.xy).x * sOpacity; gl_FragColor = vec4(vColor.rgb, a); } </code></pre> <p>It's calculated previously with</p> <pre><code>O = pow(O, 1.3); </code></pre> <p>for the best visual effect.</p> <p>I draw with color (0; 0; 0) on the black transparent canvas (0;0;0;0), but with very low opacity:</p> <pre><code>0.03 -&gt; 0.01048 0.06 -&gt; 0.0258 0.09 -&gt; 0.0437 0.12 -&gt; 0.0635 ... </code></pre> <p>I expect, that maximal value of point's color will be (0;0;0;1) (black, no transparent) after multiple drawings as on the simulator: <img src="https://i.stack.imgur.com/kl8tZ.png" alt="enter image description here"></p> <p>but it isn't so on the device: <img src="https://i.stack.imgur.com/cijMd.png" alt="enter image description here"></p> <p>Do you have any ideas, why is it so?</p> <p><strong>UPDATE:</strong></p> <p>Also manual blending works incorrect too (and with difference from standard).</p> <pre><code>glBlendFunc(GL_ONE, GL_ZERO); </code></pre> <p>Fragment shader code:</p> <pre><code>#extension GL_EXT_shader_framebuffer_fetch : require precision highp float; uniform sampler2D tShape; uniform vec4 vColor; uniform float sOpacity; varying vec4 texCoords; void main() { float a = texture2D(tShape, texCoords.xy).x * sOpacity; gl_FragColor = vec4(vColor.rgb * a, a) + (gl_LastFragData[0] * (1.0 - a)); } </code></pre> <p>Result on the simulator: <img src="https://i.stack.imgur.com/vB6g8.png" alt="enter image description here"></p> <p>Result on the device: <img src="https://i.stack.imgur.com/ypNxD.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload