Alpha Textures

Tonfilms particles patch (nice!) brought an issue back to my mind which I discussed with Oschatz a few weeks ago.
Instead of using spheres one could easily use point sprites of spheres with alpha masks. That would save lots of computing power but a basic problem with billboarding always remains: The z-sorting.
Extracting the position data from the vertex buffer, then sorting polygons by their z-value and reassembling the buffer is far too slow as a discreet patch.
Any suggestions from the developers, how to solve this task within one single node?
As this issue comes up almost regularly when working with alpha textures I would really appreciate a proper solution here.


yes, would be nice to have a ZSort node. but where to put it? after the last transform? best solution would be to have it in a Layer connection, so one could sort all layers or just groups of them. but the layer connection is only a logical connection, that means some coding for gregsen then. i dont see this in the next release…

but the sorting needs to take place at the polygon level, not so much at the layer level.

As sven said, you could do this by disassembling a vertex buffer, splitting, sorting and reassembling it again, but this not really fast, as a lot of data with usually huge spreadcounts need to be shifted around.
Having a native GetSlice for vertexbuffers and something like a 3d Bounds node for vertexbuffers (which would calculate the center points of all triangles) could speed up this process a lot. You still need to understand things, but if you do, you can implement it in an efficient way…

Basically there are two different cases we talk about. Both would need their own solution though.

  1. Sorting on polygon level:
    Rotating a sphere with a transparent texture is impossible right now.
    With every rotation the mesh has to be reassembled ordering every polygon it’s built of. I once did a module providing this function by using the simple (but therefore not too reliable) “painters algorithm” Oschatz discribed above (ordering faces by their vertices average depth). As one would expect this method is fairly slow but I guess “autosorting” as an option for the vertexbuffer would be good solution here that could be implemented very easily. I would be very glad if vvvv would offer this function.

  2. Sorting vectors in general:
    That is what I initially ment. A particle system consists of many single meshes. The spheres in Tonfilms patch could be replaced by billboarding quads showing sphere textures. Alpha masks would give them a spheric shape then.
    The problem is that we now would have to reorder the particles positions as well to draw them correctly.
    I think this still has to be done manually by using a sort node specialized on vector spreads.
    VVVVs sort node uses (wild guess…) a basic quicksort or something and vector compatibility has to be patched seperately, which is extremely slow.
    So my suggestion would be to enhance the node for multidimensional formats and provide alternative sorting algorithms.
    Probably the best one for our case is Michael Herfs optimized radix that can be found here:
    Implementation should be also no big deal in my eyes.