controlling irrlichts magfilter setting?

miner65536
Member
 
Posts: 41
Joined: Tue Aug 20, 2013 22:16

controlling irrlichts magfilter setting?

by miner65536 » Fri Oct 04, 2013 22:11

I reckon minetest would look superb if we could get irrlicht to set the magfiltering to point mode (for D3D mode anyway).
This way mip-mapping, bi-linear or aniso filtering could be enabled for the distant scenery but close up the textures would just be point sampled, so would look properly retro.
This would be the perfect setup for the default 16x16 textures.
I've looked quickly at irrlicht & it looks like point mode (D3DTEXF_POINT) cannot be set for the texture stage states, so it would need an irrlicht recompile... If i get time i will try, but I'm too busy, if someone else could try this it'd be awesome...

cheers,
Rob


PS the piece of code i was looking at in irrlicht was in CD3D9Driver.cpp
I reckon replace this lot:

// Bilinear, trilinear, and anisotropic filter
if (resetAllRenderstates ||
lastmaterial.TextureLayer[st].BilinearFilter != material.TextureLayer[st].BilinearFilter ||
lastmaterial.TextureLayer[st].TrilinearFilter != material.TextureLayer[st].TrilinearFilter ||
lastmaterial.TextureLayer[st].AnisotropicFilter != material.TextureLayer[st].AnisotropicFilter ||
lastmaterial.UseMipMaps != material.UseMipMaps)
{
if (material.TextureLayer[st].BilinearFilter || material.TextureLayer[st].TrilinearFilter || material.TextureLayer[st].AnisotropicFilter)
{
D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) &&
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) &&
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
D3DTEXTUREFILTERTYPE tftMip = material.UseMipMaps? (material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT) : D3DTEXF_NONE;

if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC)
pID3DDevice->SetSamplerState(st, D3DSAMP_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy));
pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, tftMag);
pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin);
pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip);
}
else
{
pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, D3DTEXF_POINT);
pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
}
}


with this:

pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
pID3DDevice->SetSamplerState(st, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
Last edited by miner65536 on Fri Oct 04, 2013 22:49, edited 1 time in total.
 

miner65536
Member
 
Posts: 41
Joined: Tue Aug 20, 2013 22:16

by miner65536 » Mon Oct 07, 2013 09:39

It turned out compiling irrlicht was as simple as opening the VS solution & pressing F5!
I tried this on an i5 laptop using the integrated HD4000 and after setting the mipmapping LOD bias to -1.5 its a huge improvement, distant scenery looks unconfused (I've got to try this on a decent gfx card to compare with good anisotropic filtering) But compared to the options available with the default irrlicht build & minetests settings its great, I'll post some A-B screen shots if anyone is interested.
 

Ragnar
Member
 
Posts: 850
Joined: Thu Oct 25, 2012 15:19

by Ragnar » Mon Oct 07, 2013 10:13

screenies!
Are you saying that I put an abnormal brain into a seven and a half foot long, fifty-four inch wide GORILLA?
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Mon Oct 07, 2013 11:58

miner65536 wrote:This way mip-mapping, bi-linear or aniso filtering could be enabled for the distant scenery but close up the textures would just be point sampled, so would look properly retro.


This is already possible! Enable anisotropic filtering and mip-mapping but disable bilinear and trilinear filtering.
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 5 guests

cron