beyzend wrote:
David,
I know you are probably busy but what do you think about using instancing as a way to optimize the "cube" surface extraction? (Should I start another thread? but I guess this would be relevant to AndiNo also.)
Let's say I have a single vertex buffer which contains a constant number of vertices defined for say a single 16x16x128 region. Let's also assume the vertices are in object space. Then I could simply construct lists of triangles as I extract my surface. Then I render different N sets of triangle lists for N number of regions but all with that one single vertex buffer. In my shader I would transform the vertices into it's final position in world space as I would also pass in a world transform for each set of triangle list. The other optimization is to not have coplanar triangles. I think it's doable.
This is something I have thought about as well but there are a few catches. Firstly, there is more to a vertex than it's position - there is also the material ID and the normal. Actually I'm half-thinking to remove the normal it can also be generated in the pixel shader and will allow for more vertex sharing, but that's really a seperate discussion. The point is that you can have several vertices with the same position but other different properties.
Secondly, it's not good in all scenarios. If someone wants to use PolyVox for the simplest possible task of generating one mesh which corresponds to the whole volume then they have a rather huge vertex buffer.
Although the above sounds negative, I do actually think the idea is interesting. Maybe you can also take it further. Do you actually need the vertex buffer at all? If you know you have a region of 32x32x32 and an index in the index buffer of (for example) 4096, then you can actually deduce that this would correspond to a position of (0,0,4) (I hope I got that maths right). Maybe in a geometry shader or something.
However, for now I won't be taking that route. But I will try and spend some time over the next few week improving the performance of the CubicSurfaceExtractor. I am sure I can make the meshes many times smaller, but I don't know so much about the execution time. I might me bounded by memory access - i.e. the time to simply read each voxel from memory. I'll let you know how I get on.