ok just to be sure i could have done this better (as far as i remember gl_alpha_test is not present in ogles).
Anyway once again ill describe the thing i am doing, maybe i was using wrong words or didint explain everything.
SO look at thrid image theres a floor and two blocks (now imagine there is only one face for each block - the one that faces light), we set them as alpha textures. Imagine there is also a third block not visible on the img but its there..
in the first pass i write depth values to texture = (distance from light to vertex) / lightprojectionmat_zfar this is done with depth writes (and depth test set as gl_lequal) so only closest fragments are rendered and their distance to light is written to a fbo - here i draw only lit objects (without any transparent faces)
in second pass i draw only transparent objects (like this fence) to do that without sorting i disable depth writes and depth test - so every face is rendered, whenever texture texel is not transparent i write depth value (dst from light to vertex/ lightprjmatz_far) to texture. and here i found the bug… cause i compare depth from first pass to this depth, meaning whenever some lit object is further to light, the depth value is written, but when i have more than two transparent faces there can be a case when one transparet face that is further than another transparent face writes its depth above the one that should be closer, making further transparent face not lited by shadow from closer transparent face, so actually i need to use depth testing and depth mask writes to discard fragments that are fuly transparent… let me check the results mhm
yeah seems now its working like it should i dont even need to lookup for another shadow texture to compare alpha depths, however now im thinking if i really need second fbo.
seems like no for now, still have to use different shader for alpha textures but seems like i dont need to draw to another 6 fbos…. to test it, i need do some heavy recoding so ill be out for a little while ;]