Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  [SOLVED]What makes your renderer do this???  (Read 792 times)
0 Members and 1 Guest are viewing this topic.
Offline Cakey

Full Member
**

Posts: 127



« on: 2009-03-10 22: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

JGO Kernel
*****

Posts: 3560
Medals: 30


TUER


« Reply #1 on: 2009-03-11 02:33:34 »

Perhaps you need to use glPolygonOffset...

Julien Gouesse
Offline lhkbob

JGO Neuromancer
****

Posts: 1174
Medals: 35



« Reply #2 on: 2009-03-11 12: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! Go get 'em!
Offline bienator

JGO Ninja
***

Posts: 632
Medals: 1


OutOfCoffeeException


« Reply #3 on: 2009-03-11 12: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:
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

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

Offline Cakey

Full Member
**

Posts: 127



« Reply #4 on: 2009-03-11 15: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
« League of Dukes »

JGO Kernel
*****

Posts: 5870
Medals: 255


Hand over your head.


« Reply #5 on: 2009-03-11 15: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]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.086 seconds with 21 queries.