Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Z-Sort for transparency : Intermediate

Author
Message
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 13th Sep 2004 12:11
I know many of you have had the problem where you have grass, explosions, glass, fire, water, or anything with some transparency in it (even trees!) causing a bug that would make it where you can't see objects BEHIND IT through transparent pixels. People have recommended DISABLE OBJECT ZWRITE, but THAT DIDNT WORK. Then you could see objects through objects, but that problem is no more now!

I was sick of waiting on the wonderful folks of DB (they really are wonderful, just busy) to give us a workeable Z-Sort algorithm, so I wrote one myself in native DBP. It uses some desently quick functions and tables to do fast Z-Sort calculations. I've tried it on 500 objects and kept a consistent frame rate (over 70 fps, at times up to 100fps) and that was sorting EVERY FRAME. Check the SOURCE BOX to see the code! I tried this on the new Terrain Engine so if you want to test it and you don't have the new Terrain, go get it or you'll have to wait for a repost which makes it use a matrix. Like David T's grass demo, this uses grass as the example. I didn't put any grass wrapping or fading effects in though. This example is mainly for the Z-Sort.

FEATURES:
-Fast Shift-Sort (modified Incremental-Sort)
-Hight frame rates
-Blazing fast Distance Calculations
-Only sorts when needed
-Useful for any set of objects
-Outstanding results

DISADVANTAGES:
-Distance table is integer based, so some
flaws in object too close to each-other
-Some speed issues may arise at times

Current Projects: Verious things right now. Lots of utils for game making. Hopefully something solid soon.

http://www.geocities.com/djpeterson83
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 13th Sep 2004 12:13
Also forgot to mention as a FEATURE that all needed code (except for global declarations) are in portable functions!

Current Projects: Verious things right now. Lots of utils for game making. Hopefully something solid soon.

http://www.geocities.com/djpeterson83
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 15th Sep 2004 00:44
Quote: "People have recommended DISABLE OBJECT ZWRITE, but THAT DIDNT WORK. Then you could see objects through objects"


strange, never had that problem, I think you're a bit confused with disable object zread



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 15th Sep 2004 10:56
how many objects were you dealing with and how far was their spacing from eachother? Also, were they similar in color?

When you have a ton of objects with transparency all clumped together with object Z-Write disabled, you see right through them. DISABLE OBJECT Z-WRITE and DISABLE OBJECT Z-READ are exact opposits of each other, but because of it, generate the same artifacts, just they do it in a different order.

Current Projects: Verious things right now. Lots of utils for game making. Hopefully something solid soon.

http://www.geocities.com/djpeterson83
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 16th Sep 2004 07:35
my alpha objects where on the same plane, but the problem is fixed in u5.7 anyway, which will hopefully be out soon



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 17th Sep 2004 14:24
yeah, i heard about that. I sure hope it is fixed! That would be great! I wrote this so I could deal with how things looked before the new patch came out, but I bet that patch is going to be a while still

Current Projects: Verious things right now. Lots of utils for game making. Hopefully something solid soon.

http://www.geocities.com/djpeterson83

Login to post a reply

Server time is: 2024-11-23 19:25:02
Your offset time is: 2024-11-23 19:25:02