android - GLES2.0+ framebuffer fade artifacts -
i'm writing simple test program on android using gles 2.0 or 3.0. (if solution works on 1 on other, that's i'll go with.)
problem:
- basically running strange pixel artifacts when fading colors.
- the problem can "hidden" making cutoff threshold higher fade still has patchy consistency , purpose not work.
example:
- example pictures (sorry, cant post images directly yet)
- the frame buffers resolution has been lowered make artifacts more visible.
- this issue occurs on devices tested (nexus 7 2012 , 2013, galaxy tab s 8.4, galaxy s6 edge, galaxy note 4)
- on newer devices, problem seems small pink uniform dots, on older devices seems patchy seen in linked pictures.
- running blur pass on final render out of question needs power efficient , mobile friendly.
layout:
- i create 2 frame buffers. (using gles20.gl_unsigned_short_5_6_5 format.)
- i set first 1 render target.
- i draw quad size of buffer framebuffer.
- the quads fragment shader setup render black dot moves in circle.
- the quad can take texture , blend dot.
- i switch rendering screen.
- i render quad using set render target texture.
- this process repeated each frame switching textures.
render code:
int = 0; @override public void ondrawview() { setrendertarget(mrendertexture[i]); mtestshader.settexture0(mrendertexture[(i + 1) % 2].gettexturehandle()); mtestshader.draw(mblitquad); setrendertarget(null); mblitshader.settexture0(mrendertexture[i].gettexturehandle()); mblitshader.draw(mblitquad); = ++i % 2; }
shader code:
precision highp float; uniform float u_globaltime; uniform vec3 u_resolution; uniform sampler2d u_texture0; varying vec2 v_texcoord; void main(void) { vec2 uv = v_texcoord * 2.0 - 1.0; uv.x *= u_resolution.z; vec2 pos = vec2(cos(u_globaltime), sin(u_globaltime)) * 0.5; vec4 circle = vec4(1.0 - smoothstep(0.09, 0.11, length(pos - uv))); vec4 px = max(texture2d(u_texture0, v_texcoord), circle) - 0.025; gl_fragcolor = step(0.15, px) * px; }
any on issue?
edit:
after googling on dither jerem, found gles20.gldisable(gles20.gl_dither). helps alot problem , on newer devices works perfect. on older devices i'm still running artifacting seen here.
edit2:
after more testing, switching buffer format rgb colors seems have done trick gles30.gl_unsigned_short_5_5_5_1. guess had how gpu compresses framebuffer green more noticeable. (it still helpful know specific reason why doesn't 5_6_5 format.)
final result after both fixes applied: i.imgur.com/bqsg9yj.png.
its multi-part solution, call gles20.gldisable(gles20.gl_dither), set render buffer format gles30.gl_unsigned_short_5_5_5_1, , jerem said, may able better results alpha disabled, though experimentation on device selection appeared have no effect, possible on other devices would.
Comments
Post a Comment