Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1278 times)
0 Members and 1 Guest are viewing this topic.
Offline Cakey

Junior Member





« 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...

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 Member




OutOfCoffeeException


« 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:
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 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
« League of Dukes »

JGO Overlord


Medals: 798
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  
 
 
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.

BurntPizza (14 views)
2014-09-19 03:14:18

Dwinin (32 views)
2014-09-12 09:08:26

Norakomi (58 views)
2014-09-10 13:57:51

TehJavaDev (80 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (46 views)
2014-09-07 01:13:42

Longarmx (31 views)
2014-09-07 01:12:14

Longarmx (37 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!