Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Question about the depth buffer in open gl  (Read 1593 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Posted 2003-01-22 06:07:52 »

Hi there,

This might be a clewbie question, but what is the depth buffer for?
I thought it would be so that I wouldn't have to do depth sorting by hand, but I also found out that when I want to use blending (don't we all?) I had to do depth sorting anyway to make it appear right.
So what does it do then?  Huh

Thanks,
Erik

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2003-01-22 08:09:06 »

1. Clear z buffer & enable
2. Render all solid objects with depth buffer enabled, in any order.
3. Disable z writing, but leave z testing enabled.
4. Render all transparent objects in rough back-to-front order.

Sorting per-poly is usually overkill, so a rough sort is usually sufficient. Note that depending on your blending mode, sorting may or may not have a large effect..

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #2 - Posted 2003-01-22 09:05:15 »

Quote
Sorting per-poly is usually overkill


.... but sometimes not even sufficient. Then even splitting of polygons (e.g. when they intersect) might be necessary before sorting them.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online princec

JGO Kernel


Medals: 343
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-01-22 09:49:45 »

That's why you poke your artists and get them to define convex hulls Wink

Cas Smiley

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #4 - Posted 2003-01-22 10:20:02 »

Quote
.... but sometimes not even sufficient. Then even splitting of polygons (e.g. when they intersect) might be necessary before sorting them.

Is that only for blended polygons, or also for opaque polygons?

Quote
That's why you poke your artists and get them to define convex hulls

You lost me  Roll Eyes

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2003-01-22 11:11:28 »

Quote
Is that only for blended polygons, or also for opaque polygons?


If you've got a depth buffer in use, then this is only for transparent polys. Depth buffer will handle this for you on a per-pixel level, so all will be well (assuming you've got a reasonable combination of z-buffer depth, near plane and far plane).

Convex hulls are neat because you can render everything in it in any order, with backface culling, and not worry about overlapping polys. They're also neat for pathfinding because any two points within can always be linked with a straight line. Convex hulls are very handy  Grin

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #6 - Posted 2003-01-22 18:51:49 »

I guess then that convex hulls involves defining objects with triangles only?
If that does the trick then that's pretty ingenious  Cheesy

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #7 - Posted 2003-01-23 07:58:20 »

Here's a very early demo of a game engine I'm working on with lots of transparency used:
http://www.mycgiserver.com/~movegaga/gldemo1.jnlp
(it's now a windows only web start app using lwjgl).

Now, if you look carefully, you'll notice that although every polygon (well, only quads atm) is depth-sorted (by hand), it still isn't enough: You'll see dark squares around the bouncing stars every now and then (when it occludes the far end of a wall quad). I guess I must even sort per vertex or something? Because in the cases the black blocks appear, the origins are well sorted, but the star should still be drawn after the wall it occludes even though the origin of the wall is closer. (hope I'm still making sense here)...
BTW If the wall is solid and not transparent, everything looks fine.

Or... is there a method of blending that doesn't have this side effects?
(now doing gl.blendFunc(GL.SRC_ALPHA, GL.ONE); )

Thanks,
Erik

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #8 - Posted 2003-01-23 08:00:10 »

Oh, disregard that 'sort per vertex' suggestion. That makes no sense.  Tongue Roll Eyes

Offline whome

Junior Member




Carte Noir Java


« Reply #9 - Posted 2003-01-23 19:34:01 »

I did not know, that javaplugin can download a native .dll files as well and then run it on the fly.

Your demo looked very good and run smooth on my machine, althought I did see a black squares once in a while as well.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (7 views)
2014-07-29 12:53:52

Dwinin (7 views)
2014-07-29 10:59:34

E.R. Fleming (23 views)
2014-07-29 03:07:13

E.R. Fleming (9 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (51 views)
2014-07-17 23:47:54
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!