• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Haris072

How To Solve Z buffer Fighting

15 posts in this topic

Hi,

Is there any other way to solve z buffer fighting without changing the near plane value.

I am using

gluPerspective(fov,(winWid/winHgt),0.001,100000.0);


Thanks,
0

Share this post


Link to post
Share on other sites
Change that near plane value as well as the far plane value. Now. I'm serious.
[url="http://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm"]http://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm[/url]
2

Share this post


Link to post
Share on other sites
Yes, change the near plane. 0.001 is an absolutely ridiculous value for it; unless you can demonstrate an absolute proven need to have this value for your near plane (and I highly doubt that) - change it.
0

Share this post


Link to post
Share on other sites
On What basis I have to Change to Near and far values. I am new to this opengl 3d Programming

Edit1:If I push the near value 1.0 or greater till 1.0 distance Its not possible to see in the viewport Edited by Haris072
0

Share this post


Link to post
Share on other sites
Use a 24 bit depth buffer for better precision. It is supported on everything.
http://www.opengl.org/wiki/Common_Mistakes#Depth_Buffer_Precision
1

Share this post


Link to post
Share on other sites
[quote name='Haris072' timestamp='1340274819' post='4951283']
gluPerspective(fov,(winWid/winHgt),0.001,100000.0);
[/quote]
This is not even remotely doable with the standard depth buffer - your near plane is absolutely ridonkulous in regards to the far plane.

You have two options:
* use sane near and far distances.
* use floating point depth buffer (if your target supports them).
0

Share this post


Link to post
Share on other sites
[quote name='V-man' timestamp='1340278083' post='4951298']
Use a 24 bit depth buffer for better precision. It is supported on everything.
[url="http://www.opengl.org/wiki/Common_Mistakes#Depth_Buffer_Precision"]http://www.opengl.or...uffer_Precision[/url]
[/quote]
Given his near far plane distances - that wont help.
0

Share this post


Link to post
Share on other sites
You need to explain what it is you're trying to achieve.

Assuming you're using a scale of 1 unit = 1 metre, you're asking for millimetre precision over one hundred kilometres. Which is impossible given the number of bits in the depth buffer.

Try 0.1 to 1000.0, which is really pushing it, but may be acceptable in some cases.

Basically, you need to reduce the number of zeros after the decimal point for the near value, and the number of zeros after the decimal point for the far. It's the ratio between the two that counts: you're asking for a ration of 1:100000000 which can't be expressed in a 24 bit depth buffer.

EDIT - having read you're post again, what are the furthest depth values you need? Maybe try 0.001 near to 1.0 far. Edited by mark ds
0

Share this post


Link to post
Share on other sites
If you gave us a scale for your scene we could give you better guesses as to what values you should use.
1 = centimeters?
1 = meters?

If 1 unit = 1 centimeter (Half-Life 2, GoldenEye 007, Final Fantasy VII), you could probably get away with ranges from 10.0 to 100000.0. The low value makes more of a difference than the high value, so increasing this improves your Z quality by the most amount. 100,000 is normally a ridiculous far value, but with a near of 10.0 it isn’t too bad. Still might have some Z-fighting in detailed areas at a long-medium range or somewhat-far range.

If 1 unit = 1 meter, 0.1 to 1000.0 would be the equivalent.

In any case, you generally do not need a near value smaller than the radius of your player. For example, in an FPS the player is a capsule or cylinder, both of which have some fixed radius that keeps them that distance from walls etc. Since you can’t get closer than that to anything in the scene, your near distance should be just slightly under that value. 0.95 is often reasonable if 1 unit = 1 foot.

In any case, a near value of 0.001 is never acceptable.

If you truly need large viewing distances, use [url="http://www.gamasutra.com/blogs/BranoKemen/20090812/2725/Logarithmic_Depth_Buffer.php"]logarithmic Z[/url].


L. Spiro Edited by L. Spiro
1

Share this post


Link to post
Share on other sites
A bit off topic, but I feel that someone should tell you that glu is deprecated, as is all of the fixed function pipeline. Since you are new to 3d graphics, I figure its worth mentioning that. You should read up on the programmable pipeline. Also, this is a great book that I love which helped me transition from fixed function pipeline to programmable pipeline: http://www.amazon.com/OpenGL-4-0-Shading-Language-Cookbook/dp/1849514763/ref=sr_1_1?ie=UTF8&qid=1340288671&sr=8-1&keywords=opengl+4.0+shading+language+cookbook
0

Share this post


Link to post
Share on other sites
The reason for pushing the far plane has to do with depth values being written between 0 and 1, Most depth values lie in the range .95 and up and are smashed together. If things in your scene disappear when increasing the near plane, then your objects are way too small. Try scaling them up.
0

Share this post


Link to post
Share on other sites
There is another solution to Z fighting: Multi-pass rendering. Draw your scene in multiple passes. Each pass gets the full 0-1 depth range, and your draw distance can be as long as you'll like. I know this is a good solution to drawing things in space, where the great distances may need to be handled differently that normal.
1

Share this post


Link to post
Share on other sites
[quote name='DemonRad' timestamp='1340350727' post='4951650']
yes. more than half of machines still have fixed pipeline yet. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]
But are those machines realistically in your target audience? Or are you compromising your program for the sake of hardware that nobody is even going to run it on?
0

Share this post


Link to post
Share on other sites
The real problem may be that you try to draw more than one plane at the same depth, if you have problems with depth buffer fighting. The result will be undefined, random, or flickering. Or all of the above. It is not realistic to draw two things at the same place and have any expectations on the outcome.

You have to decide what surface should be "above", and adjust the coordinates accordingly. If this doesn't help, then you need to adjust resolution (as described above).

The are special mechanisms in OpenGL that adds a small delta to target this problem. It is described in the OpenGL superbible, which I do not have access to just now.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0