opengl es - Circle masking for pool balls using shaders -
in 2d pool game using opengl es 2.0, need mask "white" , "number" textures rotate around edges of balls. have working stencils, there 2 issues:
- no anti-aliasing on stencil test, making jagged edges.
- each ball separately masked (adjacent balls otherwise bleed 1 another), , it's slow clear , recreate stencil buffer multiple times per frame.
i'm pretty sure best solutions involve shader code, i'm new shader programming (and pretty new opengl itself), , volume of results i've uncovered in research left me unsure how best proceed.
this 1 seems close need: https://gamedev.stackexchange.com/questions/98573/how-do-i-draw-a-circular-portion-of-a-texture-within-libgdx-using-an-opengl-es-s
in particular, first answer "alpha mask texture" approach, using gray-scale image alpha value final gl_fragcolor. couldn't find examples of how set shader program that. (common examples had 3 images background, foreground, , mask, , used mix() blend them).
for example, mask size , shape of whole ball, textures numbers drawn on portion of ball (and different transform matrix perspective), texture coordinates different image , mask. , couldn't find similar that.
a second alternative easier, using 'discard' pixels beyond distance^2 center. might able feather alpha. found approach: https://gist.github.com/tgfrerer/6009069
...but uses features not available in es 2.0. if provide example similar in functionality suitable es, welcome. contrasting merits of either approach.
maybe paper can help: https://www.valvesoftware.com/publications/2007/siggraph2007_alphatestedmagnification.pdf think need - , should work fine in es2.
Comments
Post a Comment