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.

DarkBASIC Professional Discussion / Z-Sort Vs. Z-Buffer Explained

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: 11th Nov 2004 05:37 Edited at: 11th Nov 2004 05:38
unfortunetely I don't believe it could work that way. If it did, pixels wouldn't know the exact distance from the camera and would, thus, not know if their distance was closer or farther.

The reason the Z-Buffer is always relative to the camera position is because technically, when you are playing games, your camera isn't moving, the world around you is moving. Same with rotation, but it looks like you are moving instead. Ever wonder why the fog doesn't have a natural circular bend at the edges of the screen? That's why! Cuz they simply use the Z distance instead of the camera's true distance to the point.


Home of DOOP, Strata Works, and Height
Gen
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 25th Nov 2004 04:16
Only thing I would like to know at the moment... can you use Z-Buffer and Z-Sort at the same time in the same game?

Soon to come... Dark IDE
New IDE for DarkBASIC Pro!
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 25th Nov 2004 16:08
Not in DBPro, at the moment.
re faze
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 26th Nov 2004 01:59
how does zfog work?
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 26th Nov 2004 02:29
On zdepth I guess.
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: 26th Nov 2004 12:00
Quote: "Only thing I would like to know at the moment... can you use Z-Buffer and Z-Sort at the same time in the same game?"


Well obviously not in DBP as there is no Z-Sort , but in commercial games Z-Sort and Z-Buffer are used together quite frequently. To answer the question I think you are getting at, yes it would be possible for Dark Basic to do both Z-Sort and Z-Buffer, however as I have never written a C++ 3D engine, I have no idea the level of work involved. If they modulerized their pipeline well, it doesn't seem it would be THAT difficult for them to allow both Z-Sort and Z-Buffer to play nicely together.

ZFog, I believe, uses the Z-Depth buffer (Z-Buffer) to blend pixels with the fog color. I think this actually happens as polygons are getting written, though, as fog doesn't necisarrily affect every object and it would virtually impossible for it to distinguish which object get fogged and which do not after the back buffer has been written to.


Home of DOOP, Strata Works, and Height
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: 10th Dec 2004 09:01
I just had a thought. I don't know if it has ever been done or if it even can be done, but what about an Alpha buffer? After the Z-Buffer plots a polygon's pixel, the Alpha buffer would plot its translucency. That way it could blend that pixel with other pixels behind it.

Pseudo Code:



Seems this would be effective at least most of the time and there would be no slow sorting involved. Of course, you would have to have another buffer of size ScreenWidth() * ScreenHeight() * 1Byte (because it is an 8-bit alpha channel), but in todays day and age, this isn't really that big a buffer.


Home of DOOP, Strata Works, and Height
Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 11th Dec 2004 07:13
Wendigo - good idea but the problem with that is there'd be nothing storing the polygons behind the alpha ones, so you'd end up with z-problems similar to the current ones behind the alpha objects. The only solution I can think of is to have a second zbuffer for the stuff behind the alpha, but then along comes overlapping transparent objects, which brings back the previous problem again.

So you could solve this problem by having multiple z-buffers all with alpha channels, but that'd use up huge amounts of memory, so you'd have to draw the line somewhere.

But then again there's probably another, much simpler, solution, but I can't think of one at the moment.

I don't suffer from insanity:

I enjoy every minute of it!
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: 14th Dec 2004 14:55
You could be right. I hadn't really thought it threw too hard. Probably the only real cure (besides sorting) would be to raytrace, and that aint' happening in real time any day soon I'll bet.


Home of DOOP, Strata Works, and Height
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 14th Dec 2004 17:30
There does seem to be some type of z-sort because if you disable zdepth on three objects, they still cover each other right from all angles.
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: 16th Dec 2004 07:44
It would depend on how they were created. If they were created in such away like the following:


Then looking from south to north would show them in the correct order, however looking north to south would cause them to appear inside of each other.


Home of DOOP, Strata Works, and Height
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 16th Dec 2004 17:11
Works for me:

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: 18th Dec 2004 12:31
I misunderstood/misread the first time. Disabling Z-Depth doesn't correct the Z-Sort problem. What Z-Depth does is renders object after the other objects have been rendered. This is used to make sure your gun doesn't poke threw walls in first person shooters, etc.... If you replace your ZDepth commands with ZWrite, you will see the problem.


Home of DOOP, Strata Works, and Height
Etienne
21
Years of Service
User Offline
Joined: 17th Jan 2004
Location: Paris
Posted: 9th Mar 2005 06:48
it's sort of annoying not to know if Zbuffer will be corrected afterward , cause right now there are major features of what i do that relies on that , i even booleaned huge polygons just so as not to get the errors but that's not dynamical , and again ... if TGC folks announce something , then swap to another stuff ...

I personnaly wouldn't want to rely on there wills to do my own stuff ..could anyone tell me if / when this is going to be fixed ? right now there are clipping when you get away from two objects intersecting so it's not corrected ...

A pixel is nothing , lots of can be all
VRMan3D
20
Years of Service
User Offline
Joined: 3rd Apr 2005
Location: New England
Posted: 3rd Apr 2005 16:04
Hi Folks,

I have run into this same issue all the time with DBPro, and it seemed to get worse with 5.7. I'm downloading 5.8 right now to see if that helps. In C++ d3d I always got around this problem by rendering the solid objects first then my alpha blended objects after (two separate render loops, as described in the above mentioned opengl article). This worked flawlessly.
\/ \/ \/ \/ \/ \/
Here's my question:
So is there a way to do this in DBPro? Can you tell the compiler to render your matrix and solid objects first, then render the smoke/explosion type alpha things after?
/\ /\ /\ /\ /\
You can see good working examples of this on my website: http://www.vrman3d.com. Download the 3D Flightsaver screensaver to see good smoke and explosions without the above mentioned artifacts.

Thanks much,
-=VRMan=-

World Famous 3D Screensavers
-- http://www.vrman3d.com --
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: 11th Apr 2005 15:17 Edited at: 11th Apr 2005 15:19
VRMan, yes you can!

Set Object Transparency Object, 2 will tell that particular object to draw after solid objects and object with Transparency set to flag 1. This is the best method to overcome this limmitation, but requires additional planning ahead on the programmers part. IMO, it's no big deal, but for people who don't even know what a Z-Buffer is, they are going to be really confused. Here's some extra info (partial list):

Set Object Transparency Object, Flag
Flag = 0: Transparency off: Draw priority = first
Flag = 1: Transparency on: Draw priority = first
Flag = 2: Transparency on: Draw priority = last
Flag = 3: Unknown (reserved for logically XORing Flags 1 and 2?)
Flag = 4: Transparency on: Draw priority = unknown. Draws full alpha only (handy for objects with single color transparency [colorkeys]).

I hope that helps a lot! If anyone knows for sure the draw order of Flag 4 or the purpose of Flag 3, please post. I'm curious!


Home of DOOP, Strata Works, and Height
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 May 2005 09:02
It's been a while since I've been able to thouroughly check what's up, but it appears that TGC has introduced Z-Sorting! If you need it, I highly suggest downloading update 5.8 or greater. Z-Sorting can be found in transparency flags 2 and 3. 1 contains no sorting and 4 doesn't need sorting (it would just slow it down with no visual difference). If you don't want Z-Sorting to take place, use either 1 or 4, depending on your transparency needs. Thanks TGC!


Home of DOOP, Strata Works, and Height

Login to post a reply

Server time is: 2025-05-30 18:40:12
Your offset time is: 2025-05-30 18:40:12