Commit e7ced16d authored by hybrid's avatar hybrid

Made the Anisotropic Filter degree configurable via the SMaterialLayer member...

Made the Anisotropic Filter degree configurable via the SMaterialLayer member which had been a bool formerly. Using the setFlag in SMaterial should still give MaxAnisotropy level as before.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2034 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a669b865
Changes in version 1.6 Changes in version 1.6
- The Anisotropy filter can now be set to the AF value per texture layer. So no forced MAX_ANISOTROPY anymore. .irr files will probably fail, though.
- AntiAlias parameter in SIrrCreationParameters is now an u8 value specifying the multisampling level (0 for disabled, 4,6,8, and others for anti-aliasing)
- D3D devices use DISCARD for windowed renderbuffers now, can be faster.
- position2d is now a synonym for vector2d. position2d is therefore marked as deprecated, although it's unlikely to be removed. - position2d is now a synonym for vector2d. position2d is therefore marked as deprecated, although it's unlikely to be removed.
- ISceneNodeAnimator now has a hasFinished() method. - ISceneNodeAnimator now has a hasFinished() method.
......
...@@ -313,8 +313,12 @@ namespace video ...@@ -313,8 +313,12 @@ namespace video
break; break;
case EMF_ANISOTROPIC_FILTER: case EMF_ANISOTROPIC_FILTER:
{ {
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) if (value)
TextureLayer[i].AnisotropicFilter = value; for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0xFF;
else
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0;
} }
break; break;
case EMF_FOG_ENABLE: case EMF_FOG_ENABLE:
...@@ -360,7 +364,7 @@ namespace video ...@@ -360,7 +364,7 @@ namespace video
case EMF_TRILINEAR_FILTER: case EMF_TRILINEAR_FILTER:
return TextureLayer[0].TrilinearFilter; return TextureLayer[0].TrilinearFilter;
case EMF_ANISOTROPIC_FILTER: case EMF_ANISOTROPIC_FILTER:
return TextureLayer[0].AnisotropicFilter; return TextureLayer[0].AnisotropicFilter!=0;
case EMF_FOG_ENABLE: case EMF_FOG_ENABLE:
return FogEnable; return FogEnable;
case EMF_NORMALIZE_NORMALS: case EMF_NORMALIZE_NORMALS:
......
...@@ -45,7 +45,7 @@ namespace video ...@@ -45,7 +45,7 @@ namespace video
TextureWrap(ETC_REPEAT), TextureWrap(ETC_REPEAT),
BilinearFilter(true), BilinearFilter(true),
TrilinearFilter(false), TrilinearFilter(false),
AnisotropicFilter(false), TextureMatrix(0) AnisotropicFilter(0), TextureMatrix(0)
{} {}
//! Copy constructor //! Copy constructor
...@@ -117,12 +117,14 @@ namespace video ...@@ -117,12 +117,14 @@ namespace video
the bilinear filtering flag is ignored. */ the bilinear filtering flag is ignored. */
bool TrilinearFilter; bool TrilinearFilter;
//! Is anisotropic filtering enabled? Default: false //! Is anisotropic filtering enabled? Default: 0, disabled
/** In Irrlicht you can use anisotropic texture filtering /** In Irrlicht you can use anisotropic texture filtering
in conjunction with bilinear or trilinear texture in conjunction with bilinear or trilinear texture
filtering to improve rendering results. Primitives filtering to improve rendering results. Primitives
will look less blurry with this flag switched on. */ will look less blurry with this flag switched on. The number gives
bool AnisotropicFilter; the maximal anisotropy degree, and is often in the range 2-16.
Value 1 is equivalent to 0, but should be avoided. */
u8 AnisotropicFilter;
//! Gets the texture transformation matrix //! Gets the texture transformation matrix
/** \return Texture matrix of this layer. */ /** \return Texture matrix of this layer. */
......
...@@ -373,12 +373,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -373,12 +373,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize,
// set the renderstates // set the renderstates
setRenderStates3DMode(); setRenderStates3DMode();
// set max anisotropy
pID3DDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy));
pID3DDevice->SetTextureStageState(1, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy));
pID3DDevice->SetTextureStageState(2, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy));
pID3DDevice->SetTextureStageState(3, D3DTSS_MAXANISOTROPY, core::min_( (DWORD) 16, Caps.MaxAnisotropy));
// so far so good. // so far so good.
return true; return true;
} }
...@@ -1470,7 +1464,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1470,7 +1464,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
lastmaterial.TextureLayer[st].TrilinearFilter != material.TextureLayer[st].TrilinearFilter || lastmaterial.TextureLayer[st].TrilinearFilter != material.TextureLayer[st].TrilinearFilter ||
lastmaterial.TextureLayer[st].AnisotropicFilter != material.TextureLayer[st].AnisotropicFilter ) lastmaterial.TextureLayer[st].AnisotropicFilter != material.TextureLayer[st].AnisotropicFilter )
{ {
if (material.TextureLayer[st].BilinearFilter || material.TextureLayer[st].TrilinearFilter || material.TextureLayer[st].AnisotropicFilter) if (material.TextureLayer[st].BilinearFilter || material.TextureLayer[st].TrilinearFilter || material.TextureLayer[st].AnisotropicFilter>1)
{ {
D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) && D3DTEXTUREFILTERTYPE tftMag = ((Caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) &&
material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; material.TextureLayer[st].AnisotropicFilter) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
...@@ -1478,6 +1472,8 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1478,6 +1472,8 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
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.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
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_MAGFILTER, tftMag); pID3DDevice->SetTextureStageState(st, D3DTSS_MAGFILTER, tftMag);
pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, tftMin); pID3DDevice->SetTextureStageState(st, D3DTSS_MINFILTER, tftMin);
pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, tftMip); pID3DDevice->SetTextureStageState(st, D3DTSS_MIPFILTER, tftMip);
......
...@@ -427,12 +427,6 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -427,12 +427,6 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize,
// set the renderstates // set the renderstates
setRenderStates3DMode(); setRenderStates3DMode();
// set maximal anisotropy
pID3DDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, min(16ul, Caps.MaxAnisotropy));
pID3DDevice->SetSamplerState(1, D3DSAMP_MAXANISOTROPY, min(16ul, Caps.MaxAnisotropy));
pID3DDevice->SetSamplerState(2, D3DSAMP_MAXANISOTROPY, min(16ul, Caps.MaxAnisotropy));
pID3DDevice->SetSamplerState(3, D3DSAMP_MAXANISOTROPY, min(16ul, Caps.MaxAnisotropy));
// store the screen's depth buffer // store the screen's depth buffer
DepthBuffers.push_back(new SDepthSurface()); DepthBuffers.push_back(new SDepthSurface());
pID3DDevice->GetDepthStencilSurface(&(DepthBuffers[0]->Surface)); pID3DDevice->GetDepthStencilSurface(&(DepthBuffers[0]->Surface));
...@@ -1794,6 +1788,8 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1794,6 +1788,8 @@ 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 tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT; D3DTEXTUREFILTERTYPE tftMip = material.TextureLayer[st].TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
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_MAGFILTER, tftMag);
pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin); pID3DDevice->SetSamplerState(st, D3DSAMP_MINFILTER, tftMin);
pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip); pID3DDevice->SetSamplerState(st, D3DSAMP_MIPFILTER, tftMip);
......
...@@ -1469,7 +1469,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria ...@@ -1469,7 +1469,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria
attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TrilinearFilter); attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TrilinearFilter);
prefix = "AnisotropicFilter"; prefix = "AnisotropicFilter";
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
attr->addBool((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].AnisotropicFilter); attr->addInt((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].AnisotropicFilter);
prefix="TextureWrap"; prefix="TextureWrap";
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrap, aTextureClampNames); attr->addEnum((prefix+core::stringc(i+1)).c_str(), material.TextureLayer[i].TextureWrap, aTextureClampNames);
...@@ -1535,7 +1535,7 @@ void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMater ...@@ -1535,7 +1535,7 @@ void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMater
outMaterial.setFlag(EMF_ANISOTROPIC_FILTER, attr->getAttributeAsBool(prefix.c_str())); outMaterial.setFlag(EMF_ANISOTROPIC_FILTER, attr->getAttributeAsBool(prefix.c_str()));
else else
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
outMaterial.TextureLayer[i].AnisotropicFilter = attr->getAttributeAsBool((prefix+core::stringc(i+1)).c_str()); outMaterial.TextureLayer[i].AnisotropicFilter = attr->getAttributeAsInt((prefix+core::stringc(i+1)).c_str());
prefix = "TextureWrap"; prefix = "TextureWrap";
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
......
...@@ -2010,9 +2010,9 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2010,9 +2010,9 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
(material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST); (material.TextureLayer[i].BilinearFilter || material.TextureLayer[i].TrilinearFilter) ? GL_LINEAR : GL_NEAREST);
#ifdef GL_EXT_texture_filter_anisotropic #ifdef GL_EXT_texture_filter_anisotropic
if (AnisotropyExtension) if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
material.TextureLayer[i].AnisotropicFilter ? MaxAnisotropy : 1.0f ); material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1);
#endif #endif
} }
......
...@@ -18,10 +18,10 @@ namespace video ...@@ -18,10 +18,10 @@ namespace video
COpenGLExtensionHandler::COpenGLExtensionHandler() : COpenGLExtensionHandler::COpenGLExtensionHandler() :
StencilBuffer(false), StencilBuffer(false),
MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), MultiTextureExtension(false), MultiSamplingExtension(false),
TextureCompressionExtension(false), TextureCompressionExtension(false),
MaxTextureUnits(1), MaxLights(1), MaxIndices(65535), MaxTextureUnits(1), MaxLights(1), MaxIndices(65535),
MaxAnisotropy(1.0f), MaxUserClipPlanes(0), MaxAnisotropy(1), MaxUserClipPlanes(0),
Version(0), ShaderLanguageVersion(0) Version(0), ShaderLanguageVersion(0)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0),
...@@ -103,7 +103,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -103,7 +103,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture]; MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture];
MultiSamplingExtension = FeatureAvailable[IRR_ARB_multisample]; MultiSamplingExtension = FeatureAvailable[IRR_ARB_multisample];
AnisotropyExtension = FeatureAvailable[IRR_EXT_texture_filter_anisotropic];
TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression];
StencilBuffer=stencilBuffer; StencilBuffer=stencilBuffer;
...@@ -400,8 +399,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -400,8 +399,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
#endif #endif
glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); glGetIntegerv(GL_MAX_LIGHTS, &MaxLights);
#ifdef GL_EXT_texture_filter_anisotropic #ifdef GL_EXT_texture_filter_anisotropic
GLint maxAniso=1; // temporary for size adaption
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropy); glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAniso);
MaxAnisotropy=(u8)maxAniso;
#endif #endif
#ifdef GL_VERSION_1_2 #ifdef GL_VERSION_1_2
if (Version>101) if (Version>101)
......
...@@ -709,7 +709,6 @@ class COpenGLExtensionHandler ...@@ -709,7 +709,6 @@ class COpenGLExtensionHandler
bool StencilBuffer; bool StencilBuffer;
bool MultiTextureExtension; bool MultiTextureExtension;
bool MultiSamplingExtension; bool MultiSamplingExtension;
bool AnisotropyExtension;
bool TextureCompressionExtension; bool TextureCompressionExtension;
// Some non-boolean properties // Some non-boolean properties
...@@ -720,7 +719,7 @@ class COpenGLExtensionHandler ...@@ -720,7 +719,7 @@ class COpenGLExtensionHandler
//! Optimal number of indices per meshbuffer //! Optimal number of indices per meshbuffer
GLint MaxIndices; GLint MaxIndices;
//! Maximal Anisotropy //! Maximal Anisotropy
f32 MaxAnisotropy; u8 MaxAnisotropy;
//! Number of user clipplanes //! Number of user clipplanes
u32 MaxUserClipPlanes; u32 MaxUserClipPlanes;
......
Test suite pass at GMT Sun Jan 04 16:23:39 2009 Test suite pass at GMT Mon Jan 05 00:23:20 2009
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