Jump to content
  • Advertisement
Sign in to follow this  
littlekid

Lines appear jagged from a distance

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a mesh of a castle that was in 3ds format which i converted to .x. However when i load the mesh, the lines/walls that appear far away look jagged and triangular. As i move closer to it, the lines will then slowly smooth out to a straight line. Is there any way to solve the jagged line problem? How do i post a image?

Share this post


Link to post
Share on other sites
Advertisement
To post an image, host it somewhere that allows offsite linking, and then just use a standard HTML img tag.

Is this castle textured? If so, what texture filtering are you using, and have you remembered to generate and use mipmaps?

Share this post


Link to post
Share on other sites
This sounds like Z-fighting - are there 'inside walls' of the castle that might be too close to the outside walls?

There's a few things you can do, such as cull faces (front or back, depending on how the mesh's triangles are made), turn up the depth buffer (to 32 bit, for example.) You could also make the castle's walls thicker (thereby reducing the tendency for them to z-fight.

A pic would be helpful.

Share this post


Link to post
Share on other sites
I am using directx and i enable z-buffering using:

g_d3d_device->SetRenderState(D3DRS_ZENABLE, true);

How do i make the z-buffer into a 32 bits or to slove the z-fighting?

[edited]
If i change the near-clip plane from 0.1f to 1.0f, everything becomes ok, but i don't wish to set the near clip plane to 1.0f because everying will get clipped too early making it unrealistic.

However i don't understand why changing the near clip plane can help solve the z-fighting?

Share this post


Link to post
Share on other sites
That is odd. Being that it's DirectX, and that I've not used it, the best possible scenario is that DirectX magically chooses the best way to handle the depth buffer, for your hardware and video mode. More likely is that it's just different than OpenGL (which I've used,) and that things like bit-values for depth-buffers just doesn't translate in to DirectX. They're both graphics APIs, working with hardware to put stuff on the screen - so, fundamentally, they're similar --- right? ;)

Share this post


Link to post
Share on other sites
Changing the near clip plane helps because it gives the z-buffer more resolution in the distance. The z-buffer is non-linear so that it always has more resolution closer to the camera and less the further you go. If the near plane is very close, a lot of the resolution is "wasted" in the immediate foreground and there's not enough bits left for the faraway stuff. You can also try to bring the far plane closer but it has much less effect.

Generally the near plane distance should be roughly 1/1000th of the far plane to be safe, if you want to support 16-bit z-buffers. Though most if not all newer video cards should support 24-bit... You see 16-bit mostly on integrated video cards, laptops and such. I have no idea how to set the depth bits in DX so you'll have to read the documentation, but it must be possible.

Share this post


Link to post
Share on other sites
Heres the picture



The portion where the wall meets the roof is jagged. However as i move the camera closer towards it, the line will straighten

Share this post


Link to post
Share on other sites
You set the depth buffer format when creating the direct3d device. Set presentation parameters:

presentParams.EnableAutoDepthStencil = TRUE;
presentParams.AutoDepthStencilFormat = ...

The available depth formats can be found in the API docs. Make sure you clear the depth buffer each frame.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!