Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 982 times)
0 Members and 1 Guest are viewing this topic.
Offline Cakey

Junior Member





« Posted 2009-03-11 03: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 Ninja


Medals: 33
Projects: 1


TUER


« Reply #1 - Posted 2009-03-11 07:33:34 »

Perhaps you need to use glPolygonOffset...

Offline lhkbob

JGO Knight


Medals: 32



« Reply #2 - Posted 2009-03-11 17: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!
Try the Free Demo of Revenge of the Titans
Offline bienator

Senior Member




OutOfCoffeeException


« Reply #3 - Posted 2009-03-11 17: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

Junior Member





« Reply #4 - Posted 2009-03-11 20: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.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #5 - Posted 2009-03-11 20: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
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (68 views)
2013-05-17 21:29:12

alaslipknot (78 views)
2013-05-16 21:24:48

gouessej (109 views)
2013-05-16 00:53:38

gouessej (104 views)
2013-05-16 00:17:58

theagentd (115 views)
2013-05-15 15:01:13

theagentd (104 views)
2013-05-15 15:00:54

StreetDoggy (149 views)
2013-05-14 15:56:26

kutucuk (173 views)
2013-05-12 17:10:36

kutucuk (170 views)
2013-05-12 15:36:09

UnluckyDevil (179 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.089 seconds with 22 queries.