Draw Ordering with Transparency Problem

Started by
4 comments, last by Sc4Freak 17 years, 1 month ago
I am currently doing my drawing in the following order: 1. Draw Objects 2. Draw Level Here's the issue. Some object contain transparency (such as a window pane). Also some walls contain transparency (such as fences). If I have a transparent wall, I can see through it fine to see the objects and other walls. However, if I have an object with a glass pane, I can only see objects through the transparent portion, and the level is not there and is instead the background color. How do I solve this issue? If I switch the order of level and objects, then if I look through an object I will see the walls but not the other objects beyond the view, and then you will not be able to see objects through transparent walls.
Advertisement
The standard method is to render solid objects first, then render transparent objects. In doing this, transparent objects must be sorted by depth, back to front, when you render them, otherwise the transparency will not look right -- as you've observed.

There are solutions for order-independent transparency using depth-peeling, but they're probably going to be harder for you (judging by the relatively naivette of your stated render process -- no offense meant, of course) to implement then simply sorting the transparent objects.
Thanks for the reply. Not meaning to sound too newbie-ish, but what is an efficient method of doing so? I have a hundred objects or so in the room, and the objects can move. They are stored in no particular order, and even if they were, they can move and change coordinates rapidly. How would I do this draw ordering efficiently from back to front?
Well, you just sort them by their depth based on the current camera. Although this might be quite a lot of sorting right at the start, generally speaking the sort order stays pretty coherent between frames, so after the initial sort is done, it's not a whole lot of work to keep them sorted, so long as you use a sort algorithm that's stable when the list is already mostly sorted.

Btw, I would generally recommend that you render landscape and building/level geometry first, and then render the objects. I'm assuming you're not currently doing any occlusion queries, so if you render the level geometry first you're more likely to have the hardware eliminate a bunch of object rendering because the level geometry blocks it out.
The reason I am showing objects before rooms, is because otherwise if you put objects after rooms, they are not visible through windows, railings on walkways, etc. Does the level/object need to be drawn at the same time? Couldn't be, too much.

I'll try the sorting thing, I hope it doesn't use up too much processing.
That is why you draw your transparent/translucent objects after your opaque ones. In other words, draw all your non-blended objects, then render all your blended objects after that.

1) Draw your non-blended terrain/level geometry
2) Draw your non-blended objects. Doing this after rendering the level geometry is likely to save processing power on objects blocked by walls, etc.
3) Draw all your blended objects
NextWar: The Quest for Earth available now for Windows Phone 7.

This topic is closed to new replies.

Advertisement