Problem with terrain texture filtering

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Actually, in DX, if you enable Anisotropic and the card doesn't support it, it will use the best that is supported in place. Maybe it would help to read up on DX - http://msdn.microsoft.com/library/defau ... ertype.asp

Another problem with these states, is how the ?: operator is used for each stage 3 times, it should be done 1 time and saved into the proper enumeration and then set using the single value into all of the calls. Here's how I know do it in IrrSpintz for DX9 -

Code: Select all

D3DTEXTUREFILTERTYPE magFilter = D3DTEXF_POINT;
D3DTEXTUREFILTERTYPE minFilter = D3DTEXF_POINT;
D3DTEXTUREFILTERTYPE mipFilter = D3DTEXF_POINT;

if( material.AnisotropicFilter )
{
	magFilter = D3DTEXF_ANISOTROPIC;
	minFilter = D3DTEXF_ANISOTROPIC;
	mipFilter = D3DTEXF_ANISOTROPIC;
}
else if( material.TrilinearFilter )
{
	magFilter = D3DTEXF_LINEAR;
	minFilter = D3DTEXF_LINEAR;
	mipFilter = D3DTEXF_LINEAR;
}
else if( material.BilinearFilter )
{
	magFilter = D3DTEXF_LINEAR;
	minFilter = D3DTEXF_LINEAR;
	mipFilter = D3DTEXF_POINT;
}

pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, mipFilter );
			
pID3DDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(1, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, mipFilter );

pID3DDevice->SetSamplerState(2, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(2, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(2, D3DSAMP_MIPFILTER, mipFilter );

pID3DDevice->SetSamplerState(3, D3DSAMP_MAGFILTER, magFilter );
pID3DDevice->SetSamplerState(3, D3DSAMP_MINFILTER, minFilter );
pID3DDevice->SetSamplerState(3, D3DSAMP_MIPFILTER, mipFilter );
Image
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Spintz wrote:Actually, in DX, if you enable Anisotropic and the card doesn't support it, it will use the best that is supported in place. Maybe it would help to read up on DX - http://msdn.microsoft.com/library/defau ... ertype.asp
I set aniso and I got point. On a 7800GTX! "Driver is free to set whatever filter they like" seems more accurate.

I forget the exact min/mip/mag settings, but it didn't give me the best aniso - I got point filtering. Docs --> bin. :mrgreen:
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Wait! Spintz is right. Irrlicht only sets the MIP filter to LINEAR when trilinear filtering is enabled. As the table above shows, it should be enabled for both trilinear and anisotropic filtering.

Like it has been mentioned, the code to set the filters is pretty complicated. I think the code posted above is much better. It might be unnecessary to check the device caps, but it isn't wrong to do it either. If it safe to expect the driver to fall back then the code would work just fine.

Travis
Last edited by vitek on Fri Jan 19, 2007 4:56 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There is no devcap for MipFilter which tests for Anisotropic filtering, so I did not set it. The cap check was added because sio2 got lots of errors when setting unsupported modes.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

As a note, this can't really be done with OpenGL because in OpenGL filtering is set on a per texture basis, not just as a state, so you have to check each texture for each stage.

sio2, maybe it's a bug in the Nvidia driver you're using, or even worse on the card! It could also be a bug in the docs with MS as well. Are there settings in the Nvidia control panel to force a certain type of filtering maybe? Similar to the AA settings, where you can force the card to do something, or leave it application controlled.
Image
Post Reply