iOs OpenGL ES 2.0 adding textures with low opacity on device and on simulator -
i have problem multiple drawing of textures in program.
blending mode is
glblendfuncseparate(gl_src_alpha, gl_one_minus_src_alpha, gl_one, gl_one_minus_src_alpha); glblendequation(gl_func_add);
the value of a-channel passed shader cpu-code.
precision highp float; uniform sampler2d tshape; uniform vec4 vcolor; uniform float sopacity; varying vec4 texcoords;\n" void main() { float = texture2d(tshape, texcoords.xy).x * sopacity; gl_fragcolor = vec4(vcolor.rgb, a); }
it's calculated with
o = pow(o, 1.3);
for best visual effect.
i draw color (0; 0; 0) on black transparent canvas (0;0;0;0), low opacity:
0.03 -> 0.01048 0.06 -> 0.0258 0.09 -> 0.0437 0.12 -> 0.0635 ...
i expect, maximal value of point's color (0;0;0;1) (black, no transparent) after multiple drawings on simulator:
but isn't on device:
do have ideas, why so?
update:
also manual blending works incorrect (and difference standard).
glblendfunc(gl_one, gl_zero);
fragment shader 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 = texture2d(tshape, texcoords.xy).x * sopacity; gl_fragcolor = vec4(vcolor.rgb * a, a) + (gl_lastfragdata[0] * (1.0 - a)); }
result on simulator:
result on device:
i'm trying understand approach wrote down equations:
this how new drawing performed (if didn't make mistake):
color = {pencil_shape}*sourcealpha + {old_paint}*(1-sourcealpha) alpha = {pencil_shape} + {old_paint}*(1-sourcealpha)
so alpha getting closer 1 on each frame, , color blended each time based on src alpha in *pencil_shape*.
questions:
- do intend use alpha in output image anything?
- is *pencil_shape* black (0, 0, 0, 0)? (besides cornes suppose has antialiasing effect)
Comments
Post a Comment