# face display problem

This topic is 4033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
So, the distance is based on the center of the faces, like (point1+point2+point3) / 3, is there a faster method?

##### Share on other sites
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

##### Share on other sites

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 !

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632995
• Total Posts
3009773
• ### Who's Online (See full list)

There are no registered users currently online

×