Sign in to follow this  

Antialiasing

This topic is 4042 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

Well ive tryed to make some Antialiasing with DirectX My app is fullscreen. .................................................... .................................................... .................................................... D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = FALSE; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferWidth = 640; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; d3dpp.MultiSampleQuality = 1;
    g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
                          D3DCREATE_HARDWARE_VERTEXPROCESSING,
                          &d3dpp, &g_pd3dDevice );
If I add those bolded lines in my code, before Creating the Device the app crashes. If I add those lines after the Creation of Device nothing happens !! I also did
g_pd3dDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS ,1);
Whats wrong? Why i cant use Antialiasing ? Because no matter how much samples i use the aliasing is the same :( Thanks..

Share this post


Link to post
Share on other sites
Quote:
Original post by Azzazelus
Well ive tryed to make some Antialiasing with DirectX

My app is fullscreen.

....................................................
....................................................
....................................................
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );

d3dpp.Windowed = FALSE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = 640;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
d3dpp.MultiSampleQuality = 1;



g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice );



If I add those bolded lines in my code, before Creating the Device the app crashes. If I add those lines after the Creation of Device nothing happens !!

I also did

g_pd3dDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS ,1);


Whats wrong? Why i cant use Antialiasing ? Because no matter how much samples i use the aliasing is the same :(

Thanks..


You don't usually get to set the quality parameter if you're using masked antialiasing, so just set it to 0. Otherwise, use D3DMULTISAMPLE_NONMASKABLE instead of D3DMULTISAMPLE_2_SAMPLES, and check your device caps for the maximum quality value (interpretation of which is in the hands of the graphics driver).

Additionally, check that your driver settings don't force antialiasing off.

Share this post


Link to post
Share on other sites
The app is still crashing if i set those values (even how u said) before the creation of device). But if i set them after tyhe creation of device it doesnt crash but antialiasing doesnt work( i guess because the device is not created with those parameter)

Later Edit: I think is crashing if i set a value larger than 4_SAMPLES (like 8,9,10,11 etc). But from the driver i can set a value larger than 4x so i supose my gfx card suport that.

[Edited by - Azzazelus on November 25, 2006 4:11:31 AM]

Share this post


Link to post
Share on other sites
You need to understand enumeration - you can't just throw values at Direct3D for things like this: you MUST verify that your hardware supports the combination first.

Read the documentation for IDirect3D9::CheckDeviceMultiSampleType() and you'll be able to generate a list of available modes.

You can also use the DXCapsViewer.exe tool and SDK samples to check what is (or is not) supported by your hardware, but always remember that these values will vary from hardware to hardware...

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by Azzazelus
I think is crashing if i set a value larger than 4_SAMPLES (like 8,9,10,11 etc). But from the driver i can set a value larger than 4x so i supose my gfx card suport that.
The values in a drivers control panel do not always have a 1:1 mapping with D3D's MSAA settings. Whilst they might be very similar you should not rely on what you see in your driver for what you can use in your application.

hth
Jack

Share this post


Link to post
Share on other sites
Ok thanks for the tips.
I also have an artifact, when 2 objects are sticked. The margins of the objects are cliping (apear and disapear) and the edges are no verry smooth when i move away from them. Also how do I set the view distance, because after a distance the objects are starting to disapear. I tryed searching google but no result (proly i dont know what to search in particulary)

Look at this:
http://img223.imageshack.us/img223/9971/efnz2.jpg

Share this post


Link to post
Share on other sites
Quote:
Original post by Sc4Freak
When calculating your projection matrix you should be able to set near and far planes for clipping.


Thanks , it worked.

As for the edges i used D3DRS_ZENABLE to false and now is better.


Later Edit: now that was a mistake i didnt noticed, how i remove that artifact without disabling D3DRS_ZENABLE (lol)
Thbaks again.

Share this post


Link to post
Share on other sites
Just don't draw polygons so near together in depth. The artifact is called "z fighting" and is caused by the fact that the local depth buffer precision isn't adequate in representing depth values so close together.

You can reduce this by moving your projection's near plane farther, so that the depth values of your scene are represented with effectively greater dynamic range. Also, if your device supports higher than 16-bit depth buffers, you gain more depth precision by using them.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
Just don't draw polygons so near together in depth. The artifact is called "z fighting" and is caused by the fact that the local depth buffer precision isn't adequate in representing depth values so close together.

You can reduce this by moving your projection's near plane farther, so that the depth values of your scene are represented with effectively greater dynamic range. Also, if your device supports higher than 16-bit depth buffers, you gain more depth precision by using them.


I looked at a depthbias tut. from codesampler and i changed my code anmd now is working.

Thanaks for ur advice..

Share this post


Link to post
Share on other sites

This topic is 4042 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