Skip to main content
GameDev.net gamedev.net
🔒 Locked

Z-fighting?

Started by NotTaxes Aug 7, 2002 at 5:28 PM 5 replies 350+ views
Original Post
NotTaxes
NotTaxes
This doesn''t seem to be a z-fighting problem, but it looks similar. I am drawing a terrain made up of a whole bunch of tris. I am trying to add water to the scene by the most expedient method possible - basically drawing a huge quad with a semi-transparent texture at a particular height. If the ground dips below the water quad, then there''s water. If not, it''s ground. The problem is that where the ''water'' intersects the land I''m getting serious triangle artefacts. I don''t think it''s z-fighting because the angle of the ground where it intersects the water quad is quite steep (around 1:1 gradient) while the water quad is completely flat. However, it looks the same. I would expect some level of triangulation, but this is ridiculous. I don''t know if it''s important, but I''m not drawing the water quad as a VB. I''m using a mesh - flat-plane mesh, 1x1x0 dimensions, scaled up to the required size and translated to the required position - instead. Seemed like a neat way to do particle effects... just draw single-plane meshes with different textures at the required xyz and size, instead of having to create VB''s and move them around.
'Doing the impossible is kind of fun' - Walt Disney
Sneftel
Sneftel
It might still be Z-fighting. The Z-buffer is notoriously imprecise far away from the near clipping plane. Have you looked into W-buffering, or making sure your near and far clipping planes are tight against the stuff you want to render?



Don''t listen to me. I''ve had too much coffee.
Coincoin
Coincoin
This is precisely what Z fighting is.

First, try placing your near clip plane as far as possible from the viewer.

If it doesn''t work, try using 24 or 32 bits z buffer.

NotTaxes
NotTaxes
OK, then I''m really missing something. I thought the clipping planes were used to do geometry culling, so putting the near plane far away would cull geometry close to the camera. I will give this a go and let you know.

Thanks
'Doing the impossible is kind of fun' - Walt Disney
DrunkenHyena
DrunkenHyena
The near and far clipping planes ARE used to clip geometry, but they are also used to define the extents of a ZBuffer. It makes sense, since nothing can be closer than the near plane, that''s a good ''closest'' value for the ZBuffer.

Precision in a ZBuffer is not linear, there is more accuracy at the near end. That''s why it is recommend that the near plane be pushed as far away as possible.

A W-Buffer is often suggested as a magic cure, because it distributes the precision evenly fro near to far. However, if you need a high level of precision, then you ay just end up distributing the error evenly across ALL your objects rather than just having a few far away.

So the first thing to do is push your near plane as far away as you reasonably can. Obviously this will be application dependant.

If that doesn''t work, you can try a W-Buffer. It may help, it may not. If you can use a 24/32-bit Z-Buffer then you should have few problems. But some video cards require that the Z-Buffer depth match the display depth, so that could require that you use a 32-bit display whether you want to or not.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
NotTaxes
NotTaxes
Cool. Thanks folks. As it turns out, I just had to move the near plane to 1 to make it all work out fine - for some reason, in a moment of poor clarity, I had set it to 0.1 :-)

Now, which parameter do I set to turn on volumetric lighting?

;-)

[edited by - NotTaxes on August 8, 2002 4:46:11 AM]
'Doing the impossible is kind of fun' - Walt Disney
Sneftel
Sneftel
quote:
Original post by NotTaxes
Now, which parameter do I set to turn on volumetric lighting?

;-)




d3dd->TurnOnCoolLookingStuff(D3D8TOCLS_ALL);




Don''t listen to me. I''ve had too much coffee.

Topic Locked

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

Sign in to reply to this topic.