android - Shaders and Uniforms. Not behaving as expected on the Galaxy S6 -
i've got distance field shader use font rendering in libgdx. takes uniform sets how bold text should be. has been working fine ages, in last week or after recent galaxy s6 update seems rolling out (in believe) i've had several reports of incorrect font rendering. (if have s6 , want see problem can download here)
my font rendering involves 3 passes, once drop shadow, once stroke , once main text. drop shadow , stroke drawn bolder main text (depending on font settings)
the problem i'm having s6 appear ignoring me changing uniform make text less bold, it's drawing text bold , merging letters each other.
below example of incorrect , correct rendering (no drop shadow in this).

the game has been out on year , installed on over 500k devices , problem has started occurring.
i don't have problematic s6 test on makes tricky. here's font rendering method.
private glyphlayout drawtext(float x, float y, charsequence str, float alignmentwidth, int alignment, boolean wrap, spritebatch drawbatch) { if (dropshadowcolour.a > 0) { font.setcolor(dropshadowcolour.r, dropshadowcolour.g, dropshadowcolour.b, dropshadowcolour.a * originalcolour.a); font.draw(drawbatch, str, x + font.getcapheight() * shadowoffset.x, y + font.getcapheight() * shadowoffset.y, alignmentwidth, alignment, wrap); font.setcolor(originalcolour); } if (strokesize != 0) { font.setcolor(strokecolour); font.draw(drawbatch, str, x, y, alignmentwidth, alignment, wrap); drawbatch.flush(); drawbatch.getshader().setuniformf("u_boldness", 0); } font.setcolor(originalcolour); return font.draw(drawbatch, str, x, y, alignmentwidth, alignment, wrap); } and fragment shader
uniform sampler2d u_texture; uniform float u_boldness; uniform float u_smoothing; varying vec4 v_color; varying vec2 v_texcoord; void main() { float distance = texture2d(u_texture, v_texcoord).b; float alpha = smoothstep(0.5 - u_boldness - u_smoothing, 0.5 - u_boldness + u_smoothing, distance); gl_fragcolor = vec4(v_color.rgb * alpha, alpha * v_color.a); } is there else should doing when setting uniform? i'm not expected begin , end shader i? pointers useful.
update if call drawbatch.end(); drawbatch.begin(); instead of drawbatch.flush(); issue resolved. however, not efficient, i'd better solution.
another update
i use around issue now
public static void safeflush(spritebatch spritebatch){ spritebatch.flush(); spritebatch.getshader().end(); spritebatch.getshader().begin(); }
Comments
Post a Comment