Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  [SOLVED]What makes your renderer do this???  (Read 2369 times)
0 Members and 1 Guest are viewing this topic.
Offline Cakey

Junior Devvie

« Posted 2009-03-11 02:18:47 »

I'm confused. I actually even borrowed my display code from another project I made which does not have this issue. Do you see how my objects when overlapping one another get all chopped up?

That's supposed to be a black cube infront of a white Box shape. The White Box shape should have some little black spots on it though(lame texture haha).

Note: these objects are perfectly fine looking when they don't overlap each other.

Any hints, or tips would be really cool as always Cheesy

Offline gouessej
« Reply #1 - Posted 2009-03-11 06:33:34 »

Perhaps you need to use glPolygonOffset...

Julien Gouesse | Personal blog | Website | Jogamp
Offline lhkbob

JGO Knight

Medals: 32

« Reply #2 - Posted 2009-03-11 16:19:27 »

If you draw different polygons so they are very nearly co-planar, the depth buffer's loss of precision will most likely have a problem figuring it out.  This results in what is called z-fighting, were some pixels of one polygon win and others, right next to it, are from the other colored polygon.  Obviously this is pretty ugly.

As gouessej said, glPolygonOffset is a way to solve this problem.  Essentially, it allows you to declare which polygon is the winner in an effective tie.  There are problems with glPolygonOffset because it can be implemented differently on different hardware, making one offset value acceptable on a Nvidia card still not look good with an ATI card.

That being said, if you need your boxes to be co-planar, you should experiment with using it; otherwise, I'd make them not on the same plane.


And, if you're positive that the boxes aren't drawn with faces on the same plane, then we have a more serious issue.  My best guess, in that case, would be that your depth buffer is screwed up and isn't being cleared correctly.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bienator

Senior Devvie


« Reply #3 - Posted 2009-03-11 16:53:47 »

also keep in mind that zbuffer's precision depends on the distance to the viewer. Z-Precision of faces rendered near to the viewer is better than faces rendered far away. You can decrease z-fighting artifacts by adjusting the z position of near and far clipping panes.
(its hard to tell from the screenshot how far the objects are actually away from the viewer Tongue)

this page explains it pretty well:

(but this won't help much for 100% coplanar faces, only fyi)

Offline Cakey

Junior Devvie

« Reply #4 - Posted 2009-03-11 19:35:40 »

Thanks everyone for the awesome explanations and links. I found out as suggested it was my stupid GluPercpective I set the NearClip to 0, changed it to 1 and it's gorgeus GL again Cheesy.

Offline Riven

« JGO Overlord »

Medals: 1341
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #5 - Posted 2009-03-11 19:42:36 »

Never ever set near-plane to 0.

At least make it 0.01 (1cm), otherwise you'll have sever z-fighting near your far-plane.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Pages: [1]
  ignore  |  Print  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!