[Solved] Transparency in BSP models

Found a bug? Report it here.

Moderator: PPS-Leaders

Locked
User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

[Solved] Transparency in BSP models

Post by x3n » Fri Dec 08, 2006 6:28 pm

Let's start with a little introduction:
I want to make a fog effect, based on several transparent sheets in a row.
The farther you look, the more sheets you see and the foggier the view gets.

But in openGL you can only see a transparent sheet through another transparent sheet, if the sheet behind is rendered BEFORE the sheet in the front. But because I have no influence on the rendering order when I build my map in GTK-radiant, I have no chance getting this fog effect working as I want.

I know, it's difficult to decide which sheet is nearer to the player (that's exactly why we use bsp models), but in my case it would be accurate enough if we just check the middle of the sheets (or maybe the nearest vertex) because I won't make difficult structures with transparent textures.

I hope this is possible :)


On the pictures below, you can see some problems caused by wrong rendering orders (the red texture is transparent too).


Image <=> Image

Image <=> Image

Image <=> Image

User avatar
patrick
Baron Vladimir Harkonnen
Posts: 350
Joined: Mon Oct 02, 2006 6:03 pm
Location: Bern

Post by patrick » Fri Dec 08, 2006 11:09 pm

Again, I looked through the code and it seems, that all transparent faces are handled in a separate list (id software did think about this problem :D)
So it actually shouldn't be a problem at all to sort them from back to front and render them in this order.
It doesn't need to be a very sophisticated algorithm (no trees or anything like this) we can tweak performance later, at the moment we got far enough :wink:

I will ask Claudio next wednesday about this topic. If Claudio is willing to do the ODE, I will try to fix this so Claudio can concentrate on ODE.

Edit: hmm... almost forgot, that stl is offering very sophisticated ordering algorithms, like quicksort. These will surely be the tools of our choice.

User avatar
patrick
Baron Vladimir Harkonnen
Posts: 350
Joined: Mon Oct 02, 2006 6:03 pm
Location: Bern

Post by patrick » Wed Jan 03, 2007 5:17 pm

I fixed the transparency bug by sorting the transparency list with a simple bubble-sort algorithm.

This algorithm works just fine now, it can be enhanced in future times.

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Post by x3n » Wed Jan 03, 2007 8:13 pm

Great! :D

*hug* :P

Locked

Who is online

Users browsing this forum: No registered users and 13 guests