Skip to main content
gamedev.net
🔒 Locked

Z-Buffer Problems

Started by voodoo 18 replies 1.3k views
Original Post
voodoo
voodoo
I have a riva tnt2 32 megs not ultra. When I draw my spaceship and rotate it it looks like part are overlapping each other. Actually it's more like artifacts I guess, but you can c certain parts through each other. Let's say my ships is composed of several parts meaning it's not one mesh but several to compose the ship: Wings, body, window etc... Now the wings are comming out of the body so there some part of the wings within the body, for it to be ok I am not suposed to see underneath the body and c part of the wing. The same mesh was ok, in PR 3.8 I am using pr4.0 Edited by - voodoo on 9/17/00 1:30:57 PM Here are some screen to help out... Pic1
Pic2 Notice the jags where the wings intercept with the body. The seconds mesh is low poly and is one single mesh for the whole object. Edited by - voodoo on 9/17/00 10:03:40 PM
Hardcore Until The End.
ChrisE
ChrisE
This is just a zbuffer precision problem. If you use a 32 bit color mode it will try to use 32 bit zbuffer precision instead of 16.

You may also want to try scaling the object up so it uses more zbuffer range (0-65535).

Chris
Author of Power Render (http:/www.powerrender.com)
voodoo
voodoo
I usually end up leaving everything on default and starting PR.
The object is not scaled what so ever, in the screen shots it was at it''s original scale.

A friend of mine with a voodoo 3500 Told me he saw no problems with the ship, but the overlay was not showing....
Hardcore Until The End.
voodoo
voodoo
Anybody have any ideas?
Hardcore Until The End.
Whirlwind
Whirlwind
Are your face single or double sided?
Meduzza
Meduzza
Try to play with "near clip" and "far clip" values.
Set near to 10 and back to 100000.
voodoo
voodoo
Have you guys looked at the screens?

Well they are single sided...

And how would I set the clip regions??
Hardcore Until The End.
Gary
Gary
This seems to be an obvoius z-buffer depth issue.

Personaly, I don''t see how the near and far clip would affect this in anyway. You get those edges because the z-buffer is not acurate enough.

Have you tested with 32-bit color to see if it still occures?

Have you tried scaling the object? make it 2 or 3x larger then zoom the camera out so the view is the same but in the zbuffer the poly''s are further apart

You could post your program (if it''s not too big) and we could test it on our video cards, since your friend of the voodoo didn''t notice a problem.
darrin
darrin
The near and far clip will effect this greatly, as the ZBuffer is stretched between the near & far clip planes. (I Think)

You can access these thru your camera.

ie
YourCamera->nearclip = 10;
YourCamera->farclip = 1000;

Otherwise, I agree about the Scale thing, work out a good scale and stick too it.


Hope this helps
Darrin

Edited by - darrin on September 19, 2000 5:56:05 PM
Gary
Gary
"The near and far clip will effect this greatly, as the ZBuffer is stretched between the near & far clip planes. (I Think)"

Interesting, I didn''t know this. Can Chris confirm this is true, as darrin doesn''t seem to be positive?


Gary
voodoo
voodoo
Darrin and Meduza are right about clipping with the cam...

The optimal values are

near = 10
far = 10000

Source


This way you dont have to play with the scale of your objects.

Another, thing I noticed is that when I choose 32 bit z-buffer the video modes defaults to 320x240 nd I cant seem to set any resolutions...

In the code if set the width and height to 800x600, it will skip the if sttement and pic the default video mode which is 640x480. It seems I cannot go higher then 640x480.

Herer is a screen with the clipping values set:
Z buffer fixed

Herer is a screen with 32 bit turned on:
32 bit on. Notice the picture is smaller because PR goes into 320x200 mode.


Either the TNT 2 really sux or these are bugs in PR??

Edited by - voodoo on September 19, 2000 11:07:55 PM
Hardcore Until The End.
Whirlwind
Whirlwind
You might need to read up on the Z buffer for the TNT 2 chip as some cards have a 32-bit Z buffer and some have a 24-bit Z buffer with an 8-bit stencil buffer. Trying to use a 32-bit Z buffer on one of the latter types (24-bit z, 8-bit stencil) can have unexpected results. Of course, this might be the wrong tree again.

The TNT 2 chip supports 320x200?

I am kind of happy I have been dragging my feet on PR as there are quite a few things I''d do that you all did that are getting set right. I''ll probably have my own bunch of questions and blame PR for my problems in a few. Just gotta finish that ESB (Extensible Small Basic) parser.
voodoo
voodoo
Yes it does support 320x200. This mode only happens when I switch 32bit rendering on!
Hardcore Until The End.
ChrisE
ChrisE
Let me see the code you''re using for choosing the video mode.

You should set it manually if you know a mode is supported, or find the closest match in the modes list.

If you''re using PR_VideoModes[0] you''ll get the smallest mode since the list is sorted from smallest to largest. The TNT just happens to support 320x200x32 and not 320x200x16 for some reason. I''ve noticed this in other cards as well.

Just picking the first video mode in the list is not something you want to do in a real application. You''ll want some kind of resolution picker in the setup dialog. For the examples to get something up and running it was fine though.
Author of Power Render (http:/www.powerrender.com)
voodoo
voodoo
Well I use your default code if the desired videomode is not suported then it picks the next best one, the coide is posted further up.


2 scenarios...


If i pic 32 bit rendering in the dialog box when it pops up i get the 320x200 if i dont pick 32 bit and I try lets say 800x600 it defaults to 640x480
Hardcore Until The End.
Nat
Nat
I have noticed Jaggies cropping up a lot of times in PR. Like on the landscape when water is cutting through it The same objects don''t show jaggies in OpenGvs. Maybe the Z - Buffer in PR needs to be improved on.
~~~º¥º -
Gary
Gary
Is it possible to have a 32-bit Z-Buffer in a 16-bit video mode?
Whirlwind
Whirlwind
I think you can set the video Z buffer to what you want but only if the card supports it. They normally work independently.
Meduzza
Meduzza
Not on my TNT. It either 32-bit back buffer + 32-bit Z buffer OR 16bit back buffer + 16 bit Z buffer. Some older cards are like this.
voodoo
voodoo
Never mind I figured out why, I could switch res! I was initializing my width and height vars out side of main, but I was also declaring other ones inside oooopppppss That what happens at 3 in the morning...
Hardcore Until The End.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.