Fred Burton wrote:
> altern wrote:
>> i am doing a 2D engine with ortographic proyection. I need to
>> implement alpha blend and also depth, so that the shapes can be drawn
>> at different z depths but also that the ones on front get blended
>> against the ones behind. I am getting problems to achive this as
>> either they wont blend or they wont get drawn on the depth they should.
> Heh, heh, heh...
> Ah... This problem ^_^
> What happens is that if you draw a shape (transparent or not), it draws
> into the z-buffer as well.
> With an opaque (non-transparent) object, this works fine, since it will
> prevent a distant object from being drawn over a near object.
> With a transparent object, a near shape will prevent a far shape (that
> fits entirely within it) from being drawn (if it's drawn after the near
> shape), and so it will not "show through".
> You must draw the transparent objects in order, from back to front to
> make sure that it works right.
> (or, in some cases you can fake it by disabling depth_mask for
> transparent things, but it's not exactly the same (the case of a whole
> bunch of mostly transparent things (alpha=0.1 maybe) works ok this way))
> Draw all the opaque shapes in any order first.
> Then sort the transparent shapes back to front.
> Then draw the transparent shapes in that order (back to front).
I had more or less understood it finally (i went to bed and next morning
read the text over again with fresh head ). But your explanation has
helped me to get a better understanding. I feel a bit lost in the middle
of matrix, buffers and all this stuff so thanks very much for giving me
a clear-easy to understand picture of the issue, i didnt het for example
that the opaque shapes could be drawn in any order, i thought they all
had to be drawn on order but the opaques before the alphas.