вторник, 11 июня 2013 г.

Small optimization trick for heavy shaders

As you may know depth buffers allows to draw 3d objects in any order and they will appear correctly - closer one will obscure farther one. But draw order is important anyway. For example, consider a scene where you're drawing from back to front. You draw an object, it passes the depth test for particular pixel and that means that pixel shader will be executed for this pixel. Next you draw another object. But since our order from back to front, this object will pass depth test and pixel shader will be executed again. Ans so on...