Anti-Aliasing

Started by
2 comments, last by Meshboy 16 years, 2 months ago
When i create a mesh with textures in 3DS Max or blender, When using it in my game-application it looks like the pixel-game before Voodoo 2 3dfx came. i want to use Anti-aliasing to smooth out the textures. i am using Managed C# with a Geforce 8800GTX card. i think it would be a preset of the 3ddevice but i don´t have the syntax and i can´t find it on the internet. where do i start? tnx prehand.
Advertisement
Hi, it may be multisample you are looking for


//here is some code to get the sample
//------------------------------------------------------------------------------------//this will return the multisample that this device can support//we will start at D3DMULTISAMPLE_6_SAMPLES and work back wards if the card canmt support it//-------------------------------------------------------------------------------------void GetMultiSampleSupported(DWORD *pQualityLevels, D3DMULTISAMPLE_TYPE *type){	HRESULT r1, r2;	DWORD QualityLevels = 0;	D3DMULTISAMPLE_TYPE types[6] = {D3DMULTISAMPLE_8_SAMPLES, D3DMULTISAMPLE_7_SAMPLES, D3DMULTISAMPLE_6_SAMPLES, D3DMULTISAMPLE_4_SAMPLES, D3DMULTISAMPLE_3_SAMPLES, D3DMULTISAMPLE_2_SAMPLES};	for(int ctr = 0; ctr < 6; ctr++)	{		QualityLevels = 0;		r1 = D3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, 											D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8, 											FALSE, types[ctr], &QualityLevels);		if(SUCCEEDED(r1))		{			//QualityLevels = 0;			r2 = D3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, 												D3DDEVTYPE_HAL, D3DFMT_D24S8, 												FALSE, types[ctr], &QualityLevels);			if(SUCCEEDED(r2))			{				//we can use this sample so lets set it				*pQualityLevels = 0;//QualityLevels;				*type = types[ctr];				//TCHAR buff[MAX_PATH];				//sprintf_s(buff, MAX_PATH, "QualityLevels = %d, Sample Level = %d", QualityLevels, types[ctr]);				//MessageBox(Hwnd, buff, "AppWin::GetMultiSampleSupported()", MB_OK);				return;//where done			}//end found back buffer and stencil buffers multi sample types		}//end found a match	}//end all sample types	//we neaver set a type so set one	*pQualityLevels = 0;	*type = D3DMULTISAMPLE_NONE;}//end GetMultiSampleSupported//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





//how to use it
D3DPRESENT_PARAMETERS D3DPresentPrams;//fill in other members as well you willDWORD QualityLevels = 0;	D3DMULTISAMPLE_TYPE multisampletype = D3DMULTISAMPLE_NONE;	GetMultiSampleSupported(&QualityLevels, &multisampletype);	D3DPresentPrams.MultiSampleType            = multisampletype;//D3DMULTISAMPLE_6_SAMPLES;//D3DMULTISAMPLE_4_SAMPLES ;//D3DMULTISAMPLE_NONE;	D3DPresentPrams.MultiSampleQuality         = QualityLevels;

I'm not sure about MDX, but in un-managed you want to turn on texture filtering (It defaults to nearest neighbour). The following will enable trilinear filtering for instance:
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
tnx this is exactly what i need.

This topic is closed to new replies.

Advertisement