face display problem

Started by
3 comments, last by kauna 16 years, 7 months ago
Hello! I'm not real smart with things like this, I usually leave 3d math to existing apis, but I'm in a position where I need to sort a mesh's faces because they have alpha textures, and not 1 bit types. I think it's called back2frontsorting. I don't want to use this PSB tree method I know of because it seems like it won't work. I have a mesh that is different every frame and rotates and such. Is there any method that can kind of guess the face order quickly just by checking the x,y,z every time? (even if it's occasionally wrong) A code example would be good. I could really use some help with this.
Advertisement
I created a face sorting algorithm that keeps track of all faces in an std::map

anytime a face is sorted, I add it to the map and calculate the distance of it from the camera. Before I render all my faces, I sort the map and then go.
So, the distance is based on the center of the faces, like (point1+point2+point3) / 3, is there a faster method?
It is really expensive and difficult to do correct transparency (take a look at depth-peeling) and PSB are one way to go, but only sorting your faces is not enough and very expensive (sorting=O(n log n)).

Ask yourself, do you really need a high level solution for transparency ?

There are already solutions for special transparency 'cases' like water, grass, trees, convex hulls etc. If you only have this kind of transparency 'problem' go for the special solutions.

--
Ashaman

Hi,

BSP is the only method presented here to give a perfect back to front order of translucent surfaces. However, with modern hardware, BSP isn't really efficient as it is evaluated on CPU. BSP does work, but personally I wouldn't use it on very complex models. You can google for implementation details.

Distance based sorting will fail at certain situations (e.g. surfaces intersecting each other, etc).

I suggest studying different alpha drawing methods as they produce different artefacts on different cases.

Good luck !

This topic is closed to new replies.

Advertisement