Changed the support for anisotropic filtering in osg::Texture so that it
is now controlled via the setMaxAnisotropy(float) method, and is set up independently for the mag filter mode, which it previously was done.
This commit is contained in:
@@ -180,8 +180,10 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom
|
||||
|
||||
// set up anistropic filtering.
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::ANISOTROPIC);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
|
||||
texture->setMaxAnisotropy(2.0f);
|
||||
|
||||
// add the transform node to root group node.
|
||||
top_transform->addChild(createTexturedItem(local_offset,texture,geometry));
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ class TextureCallback : public osg::NodeCallback
|
||||
_filterRange.push_back(osg::Texture::NEAREST);
|
||||
_filterRange.push_back(osg::Texture::NEAREST_MIPMAP_LINEAR);
|
||||
_filterRange.push_back(osg::Texture::NEAREST_MIPMAP_NEAREST);
|
||||
_filterRange.push_back(osg::Texture::ANISOTROPIC);
|
||||
_currPos = 0;
|
||||
_prevTime = 0.0;
|
||||
}
|
||||
@@ -240,7 +239,8 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom
|
||||
|
||||
// set up anistropic filtering.
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::ANISOTROPIC);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
texture->setMaxAnisotropy(2.0f);
|
||||
|
||||
// add the transform node to root group node.
|
||||
top_transform->addChild(createTexturedItem(local_offset,texture,geometry));
|
||||
|
||||
@@ -19,26 +19,27 @@ using namespace osg;
|
||||
Texture::DeletedTextureObjectCache Texture::s_deletedTextureObjectCache;
|
||||
|
||||
Texture::Texture():
|
||||
_unrefImageAfterApply(false),
|
||||
_target(GL_TEXTURE_2D),
|
||||
_wrap_s(CLAMP),
|
||||
_wrap_t(CLAMP),
|
||||
_wrap_r(CLAMP),
|
||||
_min_filter(LINEAR_MIPMAP_LINEAR), // trilinear
|
||||
_mag_filter(LINEAR),
|
||||
_texParamtersDirty(true),
|
||||
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
|
||||
_internalFormatValue(0),
|
||||
_borderColor(0.0, 0.0, 0.0, 0.0),
|
||||
_textureWidth(0),
|
||||
_textureHeight(0),
|
||||
_subloadMode(OFF),
|
||||
_subloadTextureOffsetX(0),
|
||||
_subloadTextureOffsetY(0),
|
||||
_subloadImageOffsetX(0),
|
||||
_subloadImageOffsetY(0),
|
||||
_subloadImageWidth(0),
|
||||
_subloadImageHeight(0)
|
||||
_unrefImageAfterApply(false),
|
||||
_target(GL_TEXTURE_2D),
|
||||
_wrap_s(CLAMP),
|
||||
_wrap_t(CLAMP),
|
||||
_wrap_r(CLAMP),
|
||||
_min_filter(LINEAR_MIPMAP_LINEAR), // trilinear
|
||||
_mag_filter(LINEAR),
|
||||
_maxAnisotropy(1.0f),
|
||||
_texParamtersDirty(true),
|
||||
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
|
||||
_internalFormatValue(0),
|
||||
_borderColor(0.0, 0.0, 0.0, 0.0),
|
||||
_textureWidth(0),
|
||||
_textureHeight(0),
|
||||
_subloadMode(OFF),
|
||||
_subloadTextureOffsetX(0),
|
||||
_subloadTextureOffsetY(0),
|
||||
_subloadImageOffsetX(0),
|
||||
_subloadImageOffsetY(0),
|
||||
_subloadImageWidth(0),
|
||||
_subloadImageHeight(0)
|
||||
{
|
||||
_handleList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
_modifiedTag.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
|
||||
@@ -57,6 +58,7 @@ Texture::Texture(const Texture& text,const CopyOp& copyop):
|
||||
_wrap_r(text._wrap_r),
|
||||
_min_filter(text._min_filter),
|
||||
_mag_filter(text._mag_filter),
|
||||
_maxAnisotropy(text._maxAnisotropy),
|
||||
_texParamtersDirty(false),
|
||||
_internalFormatMode(text._internalFormatMode),
|
||||
_internalFormatValue(text._internalFormatValue),
|
||||
@@ -191,6 +193,15 @@ const Texture::FilterMode Texture::getFilter(const FilterParameter which) const
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::setMaxAnisotropy(float anis)
|
||||
{
|
||||
if (_maxAnisotropy!=anis)
|
||||
{
|
||||
_maxAnisotropy = anis;
|
||||
_texParamtersDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Force a recompile on next apply() of associated OpenGL texture objects.*/
|
||||
void Texture::dirtyTextureObject()
|
||||
{
|
||||
@@ -207,11 +218,6 @@ void Texture::dirtyTextureObject()
|
||||
void Texture::apply(State& state) const
|
||||
{
|
||||
|
||||
// Texture* texture = const_cast<Texture*>(this);
|
||||
// texture->_min_filter = LINEAR_MIPMAP_LINEAR;
|
||||
// texture->_mag_filter = ANISOTROPIC;
|
||||
|
||||
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const uint contextID = state.getContextID();
|
||||
@@ -314,13 +320,9 @@ void Texture::applyTexParameters(GLenum target, State&) const
|
||||
glTexParameteri( target, GL_TEXTURE_WRAP_T, wt );
|
||||
|
||||
glTexParameteri( target, GL_TEXTURE_MIN_FILTER, _min_filter);
|
||||
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, _mag_filter);
|
||||
|
||||
if (s_borderClampSupported)
|
||||
{
|
||||
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, _borderColor.ptr());
|
||||
}
|
||||
|
||||
if (_mag_filter == ANISOTROPIC)
|
||||
if (_maxAnisotropy>1.0f)
|
||||
{
|
||||
// check for support for anisotropic filter,
|
||||
// note since this is static varible it is intialised
|
||||
@@ -333,18 +335,16 @@ void Texture::applyTexParameters(GLenum target, State&) const
|
||||
{
|
||||
// note, GL_TEXTURE_MAX_ANISOTROPY_EXT will either be defined
|
||||
// by gl.h (or via glext.h) or by include/osg/Texture.
|
||||
glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, LINEAR);
|
||||
glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, _maxAnisotropy);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (s_borderClampSupported)
|
||||
{
|
||||
glTexParameteri( _target, GL_TEXTURE_MAG_FILTER, _mag_filter);
|
||||
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, _borderColor.ptr());
|
||||
}
|
||||
|
||||
|
||||
_texParamtersDirty=false;
|
||||
|
||||
}
|
||||
|
||||
@@ -652,12 +652,13 @@ StateSet* Attr::createOsgStateSet()
|
||||
case MAG_FILTER_BICUBIC:
|
||||
case MAG_FILTER_BICUBIC_GEQUAL:
|
||||
case MAG_FILTER_BICUBIC_LEQUAL:
|
||||
osgTexture->setFilter(osg::Texture::MAG_FILTER, Texture::ANISOTROPIC);
|
||||
osgTexture->setFilter(osg::Texture::MAG_FILTER, Texture::LINEAR);
|
||||
osgTexture->setMaxAnisotropy(2.0f);
|
||||
break;
|
||||
|
||||
// case MAG_FILTER_ADD_DETAIL:
|
||||
// case MAG_FILTER_MODULATE_DETAIL:
|
||||
// osgTexture->setFilter(osg::Texture::MAG_FILTER, Texture::ANISOTROPIC);
|
||||
// osgTexture->setFilter(osg::Texture::MAG_FILTER, Texture::LINEAR);
|
||||
// break;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,15 @@ bool Texture_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("maxAnisotropy %f"))
|
||||
{
|
||||
float anis=1.0f;
|
||||
fr[1].getFloat(anis);
|
||||
texture.setMaxAnisotropy(anis);
|
||||
fr +=2 ;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
Texture::InternalFormatMode mode;
|
||||
if (fr[0].matchWord("internalFormatMode") && Texture_matchInternalFormatModeStr(fr[1].getStr(),mode))
|
||||
{
|
||||
@@ -198,6 +207,7 @@ bool Texture_writeLocalData(const Object& obj, Output& fw)
|
||||
|
||||
fw.indent() << "min_filter " << Texture_getFilterStr(texture.getFilter(Texture::MIN_FILTER)) << std::endl;
|
||||
fw.indent() << "mag_filter " << Texture_getFilterStr(texture.getFilter(Texture::MAG_FILTER)) << std::endl;
|
||||
fw.indent() << "maxAnisotropy " << texture.getMaxAnisotropy() << std::endl;
|
||||
|
||||
fw.indent() << "internalFormatMode " << Texture_getInternalFormatModeStr(texture.getInternalFormatMode()) << std::endl;
|
||||
|
||||
@@ -264,7 +274,7 @@ bool Texture_matchFilterStr(const char* str,Texture::FilterMode& filter)
|
||||
else if (strcmp(str,"LINEAR_MIPMAP_NEAREST")==0) filter = Texture::LINEAR_MIPMAP_NEAREST;
|
||||
else if (strcmp(str,"NEAREST_MIPMAP_LINEAR")==0) filter = Texture::NEAREST_MIPMAP_LINEAR;
|
||||
else if (strcmp(str,"LINEAR_MIPMAP_LINEAR")==0) filter = Texture::LINEAR_MIPMAP_LINEAR;
|
||||
else if (strcmp(str,"ANISOTROPIC")==0) filter = Texture::ANISOTROPIC;
|
||||
else if (strcmp(str,"ANISOTROPIC")==0) filter = Texture::LINEAR;
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
@@ -280,7 +290,6 @@ const char* Texture_getFilterStr(Texture::FilterMode filter)
|
||||
case(Texture::LINEAR_MIPMAP_NEAREST): return "LINEAR_MIPMAP_NEAREST";
|
||||
case(Texture::NEAREST_MIPMAP_LINEAR): return "NEAREST_MIPMAP_LINEAR";
|
||||
case(Texture::LINEAR_MIPMAP_LINEAR): return "LINEAR_MIPMAP_LINEAR";
|
||||
case(Texture::ANISOTROPIC): return "ANISOTROPIC";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ using namespace osgUtil;
|
||||
|
||||
void Optimizer::optimize(osg::Node* node, unsigned int options)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
if (options & COMBINE_ADJACENT_LODS)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user