Sign in to follow this  

how do i stop rough edges on 3d model during render

This topic is 4659 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 .x model loaded into direct X, when moving around the world from a distance the polygons in the distance loose their shape, then when you move close up to them they return to what they actually are. Is there a way i can stop these jagged edges appearing? View From a distance http://img.photobucket.com/albums/v38/bigbrother_200uk/jagged.jpg View close up http://img.photobucket.com/albums/v38/bigbrother_200uk/normal.jpg

Share this post


Link to post
Share on other sites
Try moving your near plane farther when creating the projection matrix. The artifacts seem a lot like what z-buffer inaccuracy would cause.

Also, how big is the environment exactly? The problems might also be due floating-point inaccuracies.

Share this post


Link to post
Share on other sites
Quote:
Original post by bigbrother2000
i've changed the near clipping plane from 1.0 to 15.0 and its worked a treat, do you know why this was causing the problem?


The accuracy of your depth buffer is based on the ratio between your near and far clipping plane distances. If you near clip is at 1.0, and your far clip is at 100.0 you get 1/100 = 0.01 accuracy ratio ... if you move your front buffer forwards to say 15.0 you get 15/100 = .15 which is much higher and hence more accurate. So you should make the gap between the near and far clip panes as small as possible for best results.

Share this post


Link to post
Share on other sites
thanks kaysik and Nik02 for your help. One other thing, many games out now have an antialaising feature, is this like an inbuilt function in directx to smooth out the rendered scene or is it complex algorithms they have created themselves.

Share this post


Link to post
Share on other sites
Anti-Aliasing is a built in video card feature. It can also be emulated on cars without the feature.

To enable it, you need to set the MultiSampleType property of the device's present parameters when you create the device, like so:


D3DPRESENT_PARAMETERS d3dpp;
d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;

Share this post


Link to post
Share on other sites
thanks sirob but that cause my application not to load, it compiled ok just wouldn't run. Its using directX 8 if that makes a difference. I looked at the online documentation and had this but cannot see any effect when it renders:

BOOL cGraphics::AntiAliasing(BOOL Enable)
{
if(m_pD3DDevice == NULL)
return FALSE;

if(FAILED(m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, Enable)))
return FALSE;

// Set anitaliasing type
if(Enable == TRUE) {
m_pD3DDevice->SetRenderState(D3DRS_SHADEMODE , D3DSHADE_GOURAUD );

}

return TRUE;
}

Share this post


Link to post
Share on other sites
Shade mode has absolutely nothing to do with antialiasing; it defines how the rasterizer interpolates between vertex data, "flat" being no interpolation (use first vertex's values across entire tri), and "gouraud" being linear interpolation.

To enable antialiasing, you should set a couple of members of your presentation parameters structure to reflect your needs, as Sirob said. The swap effect is required to be "discard" for the antialiasing to work. With render state "antialias enable", you can set the application of the technique on and off as you need, without reseting the device.

Share this post


Link to post
Share on other sites

This topic is 4659 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.

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