astiopin / sdf_atlas

SDF font atlas generation tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advice for WebGL1

CraigglesO opened this issue · comments

Hello, I somewhat ported your work to a WebGL2 implementation and it worked flawlessly at building SDFs real time for my mapping engine. Really really cool. However, I want WEBGL1 compatibility for mobile and it turns out not all mobile devices support the gl_FragDepth extension.

Is it possible to tweak the fragment shader to not need fragment depth? I can't currently think of a way, since the quads overlap quite a bit, but I figured you had more time to research this subject and had some less efficient methods you came across.

Thanks,
Craig.

Checked, and it seems IOS safari supports EXT_blend_minmax.

Turns out that when drawing the lines, I can just not use depth testing but force a color max during blend.

gl.blendFunc(gl.ONE, gl.ZERO)
gl.blendEquation(gl.MAX)

Couldn't find a font I've been using where this wasn't working and in webgl this is much cheaper as the FBO no longer needs a depth buffer, only the stencil buffer