[index]

Anton's Research Ramblings

26 June 2012

Rendering Multiple Objects, Blending

So, after a lot of pain I figured it out. I booted into Windows and used Chrome's debugging console, which gave me a little more feedback than Firefox's. This was the key. Using the new error message (attribs not setup properly, causing failure of drawArrays), I trawled the Intertubes. The official documentation was rubbish, but I found a forum post.

Wow! How laborious. The on-line tutorials make a complete oversight of this, because they tend not to use a different shader, or use a shader with the same attributes, and therefore never need to make this switch-over. This is the problem with "learn by doing" examples, which don't generalise or scale-up well, rather than "explain how each function works in detail" instructions. My other issue is with Khronos - if the API really must use these antique "bind/unbind", "use", "enable" type of functions that affect other functions, then it is imperitive to state that in those dependent functions. So often you find yourself unsure if a GL object should be bound or not bound when you call a certain function; it leads to (a) mystery bugs - an avoidable programming obstacle (b) badly written programmes of the "bind everything everywhere" sort.

Blending to fake transparency was pretty similar to other GL implementations, but I actually think that the tutorials on the web are, once again, misleading, and a little incorrect. The most popular series suggests disabled depth-sorting, which is not correct - disabling depth masking is appropriate technique to use. It also suggests using a non-standard blend mode. I upgraded my shaders editing demo with these new bits and pieces. I might write a tutorial to correct some of these traps.