sorting - OpenGL, alpha blending with packed buffer and multiple textures -


i'm drawing simple 2d scene containing rectangles. have 1 floatbuffer put x, y, z, r, g, b, a, u, , v data each vertex. draw using gldrawarrays , gl_triangle_strip, keeping rectangles separate degenerate vertices.

to facilitate use of multiple textures, keep separate float arrays each texture's draw calls. texture binded, float array put floatbuffer, , draw. next texture binded , continues until have drawn of textures render.

i use orthographic projection can use z coordinates , gl_depth_test setting depth independently of draw order.

to use alpha blending, every piece of advice on internet seems say:

gles20.glenable(gles20.gl_blend); gles20.glblendfunc(gles20.gl_src_alpha, gles20.gl_one_minus_src_alpha); 

this works fine per each texture's "draw", because have draw calls sorted in buffer front before drawing. have no way correctly draw texture2 under partially transparent texture1 because of depth test , texture1 being drawn before texture2. texture1 chops off overlapping part of texture2 because depth test says texture1 in front of texture2.

the ways see around 1) using 1 texture in whole program, , 2) not using transparent textures. neither of these acceptable options.

basically, need way have alpha blending without needing sort back-to-front. possible?

it sounds might need depth peeling. here's pdf shows how it.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -