Commit d5deb716 authored by hybrid's avatar hybrid

Add a new material flag which can disable mipmap usage completely via a boolean switch.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3273 dfc29bdd-3216-0410-991c-e03cc46cb475
parent aa446ecb
...@@ -75,7 +75,10 @@ namespace video ...@@ -75,7 +75,10 @@ namespace video
EMF_COLOR_MASK = 0x8000, EMF_COLOR_MASK = 0x8000,
//! ColorMaterial enum for vertex color interpretation //! ColorMaterial enum for vertex color interpretation
EMF_COLOR_MATERIAL = 0x10000 EMF_COLOR_MATERIAL = 0x10000,
//! Flag for enabling/disabling mipmap usage
EMF_USE_MIP_MAPS = 0x20000
}; };
} // end namespace video } // end namespace video
......
...@@ -186,6 +186,7 @@ namespace video ...@@ -186,6 +186,7 @@ namespace video
case EMF_NORMALIZE_NORMALS: material.NormalizeNormals = Material.NormalizeNormals; break; case EMF_NORMALIZE_NORMALS: material.NormalizeNormals = Material.NormalizeNormals; break;
case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break; case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break; case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
case EMF_USE_MIP_MAPS: material.UseMipMaps = Material.UseMipMaps; break;
case EMF_BILINEAR_FILTER: material.TextureLayer[0].BilinearFilter = Material.TextureLayer[0].BilinearFilter; break; case EMF_BILINEAR_FILTER: material.TextureLayer[0].BilinearFilter = Material.TextureLayer[0].BilinearFilter; break;
case EMF_TRILINEAR_FILTER: material.TextureLayer[0].TrilinearFilter = Material.TextureLayer[0].TrilinearFilter; break; case EMF_TRILINEAR_FILTER: material.TextureLayer[0].TrilinearFilter = Material.TextureLayer[0].TrilinearFilter; break;
case EMF_ANISOTROPIC_FILTER: material.TextureLayer[0].AnisotropicFilter = Material.TextureLayer[0].AnisotropicFilter; break; case EMF_ANISOTROPIC_FILTER: material.TextureLayer[0].AnisotropicFilter = Material.TextureLayer[0].AnisotropicFilter; break;
......
...@@ -197,7 +197,7 @@ namespace video ...@@ -197,7 +197,7 @@ namespace video
ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL), ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
ColorMaterial(ECM_DIFFUSE), ColorMaterial(ECM_DIFFUSE),
Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), ZWriteEnable(true), Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), ZWriteEnable(true),
BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), NormalizeNormals(false) BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), NormalizeNormals(false), UseMipMaps(true)
{ } { }
//! Copy constructor //! Copy constructor
...@@ -246,6 +246,7 @@ namespace video ...@@ -246,6 +246,7 @@ namespace video
AntiAliasing = other.AntiAliasing; AntiAliasing = other.AntiAliasing;
ColorMask = other.ColorMask; ColorMask = other.ColorMask;
ColorMaterial = other.ColorMaterial; ColorMaterial = other.ColorMaterial;
UseMipMaps = other.UseMipMaps;
return *this; return *this;
} }
...@@ -377,6 +378,10 @@ namespace video ...@@ -377,6 +378,10 @@ namespace video
/** Always use this if the mesh lit and scaled. Default: false */ /** Always use this if the mesh lit and scaled. Default: false */
bool NormalizeNormals:1; bool NormalizeNormals:1;
//! Shall mipmaps be used if available
/** Sometimes, disabling mipmap usage can be useful. Default: true */
bool UseMipMaps:1;
//! Gets the texture transformation matrix for level i //! Gets the texture transformation matrix for level i
/** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES. /** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES.
\return Texture matrix for texture level i. */ \return Texture matrix for texture level i. */
...@@ -492,6 +497,8 @@ namespace video ...@@ -492,6 +497,8 @@ namespace video
case EMF_COLOR_MATERIAL: case EMF_COLOR_MATERIAL:
ColorMaterial = value?ECM_DIFFUSE:ECM_NONE; ColorMaterial = value?ECM_DIFFUSE:ECM_NONE;
break; break;
case EMF_USE_MIP_MAPS:
UseMipMaps = value;
default: default:
break; break;
} }
...@@ -545,6 +552,8 @@ namespace video ...@@ -545,6 +552,8 @@ namespace video
return (ColorMask!=ECP_NONE); return (ColorMask!=ECP_NONE);
case EMF_COLOR_MATERIAL: case EMF_COLOR_MATERIAL:
return (ColorMaterial != ECM_NONE); return (ColorMaterial != ECM_NONE);
case EMF_USE_MIP_MAPS:
return UseMipMaps;
} }
return false; return false;
...@@ -577,7 +586,8 @@ namespace video ...@@ -577,7 +586,8 @@ namespace video
NormalizeNormals != b.NormalizeNormals || NormalizeNormals != b.NormalizeNormals ||
AntiAliasing != b.AntiAliasing || AntiAliasing != b.AntiAliasing ||
ColorMask != b.ColorMask || ColorMask != b.ColorMask ||
ColorMaterial != b.ColorMaterial; ColorMaterial != b.ColorMaterial ||
UseMipMaps != b.UseMipMaps;
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i) for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
{ {
different |= (TextureLayer[i] != b.TextureLayer[i]); different |= (TextureLayer[i] != b.TextureLayer[i]);
......
...@@ -1585,7 +1585,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1585,7 +1585,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
const D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && const D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) &&
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
const D3DTEXTUREFILTERTYPE tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; const D3DTEXTUREFILTERTYPE tftMip = material.UseMipMaps? D3DTEXF_NONE : (material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT);
if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC) if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC)
pID3DDevice->SetTextureStageState(st, D3DTSS_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy)); pID3DDevice->SetTextureStageState(st, D3DTSS_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy));
......
...@@ -2287,7 +2287,7 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -2287,7 +2287,7 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && D3DTEXTUREFILTERTYPE tftMin = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) &&
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
D3DTEXTUREFILTERTYPE tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; D3DTEXTUREFILTERTYPE tftMip = material.UseMipMaps? D3DTEXF_NONE : (material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT);
if (tftMag==D3DTEXF_ANISOTROPIC || tftMin == D3DTEXF_ANISOTROPIC) 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_MAXANISOTROPY, core::min_((DWORD)material.TextureLayer[st].AnisotropicFilter, Caps.MaxAnisotropy));
......
...@@ -2745,7 +2745,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2745,7 +2745,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
(material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST);
if (material.getTexture(i) && material.getTexture(i)->hasMipMaps()) if (material.getTexture(i) && material.getTexture(i)->hasMipMaps() && material.UseMipMaps)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
material.TextureLayer[i].TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR : material.TextureLayer[i].TrilinearFilter ? GL_LINEAR_MIPMAP_LINEAR :
material.TextureLayer[i].BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST : material.TextureLayer[i].BilinearFilter ? GL_LINEAR_MIPMAP_NEAREST :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment