Added options for controlling mipmapping and aniso-tropic filtering.

This commit is contained in:
Robert Osfield 2004-06-08 13:58:36 +00:00
parent ba7a7fe638
commit 65d0293778
3 changed files with 78 additions and 10 deletions

View File

@ -186,13 +186,13 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("--compressed","Use OpenGL compression on destination imagery");
arguments.getApplicationUsage()->addCommandLineOption("--RGB_16","Use 16bit RGB destination imagery");
arguments.getApplicationUsage()->addCommandLineOption("--RGB_24","Use 24bit RGB destination imagery");
arguments.getApplicationUsage()->addCommandLineOption("","");
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
arguments.getApplicationUsage()->addCommandLineOption("--max-visible-distance-of-top-level","Set the maximum visiable distance that the top most tile can be viewed at");
arguments.getApplicationUsage()->addCommandLineOption("--radius-to-max-visible-distance-ratio","Set the maximum visiable distance ratio for all tiles apart from the top most tile. The maximum visuble distance is computed from the ratio * tile radius.");
arguments.getApplicationUsage()->addCommandLineOption("--no-mip-mapping","Disable mip mapping of textures");
arguments.getApplicationUsage()->addCommandLineOption("--mip-mapping-hardware","Use mip mapped textures, and generate the mipmaps in hardware when available.");
arguments.getApplicationUsage()->addCommandLineOption("--mip-mapping-imagery","Use mip mapped textures, and generate the mipmaps in imagery.");
arguments.getApplicationUsage()->addCommandLineOption("--max-anisotropy","Max anisotropy level to use when texturing, defaults to 1.0.");
// arguments.getApplicationUsage()->addCommandLineOption("","");
// create DataSet.
osg::ref_ptr<osgTerrain::DataSet> dataset = new osgTerrain::DataSet;
@ -228,6 +228,17 @@ int main( int argc, char **argv )
while (arguments.read("--RGB_16")) { dataset->setTextureType(osgTerrain::DataSet::RGB_16_BIT); }
while (arguments.read("--RGB_24")) { dataset->setTextureType(osgTerrain::DataSet::RGB_24_BIT); }
while (arguments.read("--no-mip-mapping")) { dataset->setMipMappingMode(osgTerrain::DataSet::NO_MIP_MAPPING); }
while (arguments.read("--mip-mapping-hardware")) { dataset->setMipMappingMode(osgTerrain::DataSet::MIP_MAPPING_HARDWARE); }
while (arguments.read("--mip-mapping-imagery")) { dataset->setMipMappingMode(osgTerrain::DataSet::MIP_MAPPING_IMAGERY); }
float maxAnisotropy;
while (arguments.read("--max-anisotropy",maxAnisotropy))
{
dataset->setMaxAnisotropy(maxAnisotropy);
}
dataset->setDestinationTileBaseName("output");
dataset->setDestinationTileExtension(".ive");
@ -247,6 +258,18 @@ int main( int argc, char **argv )
dataset->setSkirtRatio(skirtRatio);
}
float maxVisibleDistanceOfTopLevel;
while (arguments.read("--max-visible-distance-of-top-level",maxVisibleDistanceOfTopLevel))
{
dataset->setMaximumVisibleDistanceOfTopLevel(maxVisibleDistanceOfTopLevel);
}
float radiusToMaxVisibleDistanceRatio;
while (arguments.read("--radius-to-max-visible-distance-ratio",radiusToMaxVisibleDistanceRatio))
{
dataset->setRadiusToMaxVisibleDistanceRatio(radiusToMaxVisibleDistanceRatio);
}
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{

View File

@ -909,9 +909,25 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
void setTextureType(TextureType type) { _textureType = type; }
TextureType getTextureType() const { return _textureType; }
void setMaxAnisotropy(float d) { _maxAnisotropy = d; }
float getMaxAnisotropy() const { return _maxAnisotropy; }
enum MipMappingMode
{
NO_MIP_MAPPING, /// disable mip mapping - use LINEAR, LINEAR filters.
MIP_MAPPING_HARDWARE, /// use mip mapping, dynamically compute them in hardware if supported
MIP_MAPPING_IMAGERY /// use mip mapping, and store imagery along with associated mip maps.
};
void setMipMappingMode(MipMappingMode mipMappingMode) { _mipMappingMode = mipMappingMode; }
MipMappingMode getMipMappingMode() const { return _mipMappingMode; }
void setUseLocalTileTransform(bool flag) { _useLocalTileTransform = flag; }
bool getUseLocalTileTransform() const { return _useLocalTileTransform; }
void setDecorateGeneratedSceneGraphWithCoordinateSystemNode(bool flag) { _decorateWithCoordinateSystemNode = flag; }
bool getDecorateGeneratedSceneGraphWithCoordinateSystemNode() const { return _decorateWithCoordinateSystemNode; }
@ -979,6 +995,9 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced
DatabaseType _databaseType;
GeometryType _geometryType;
TextureType _textureType;
float _maxAnisotropy;
MipMappingMode _mipMappingMode;
bool _useLocalTileTransform;
bool _decorateWithCoordinateSystemNode;

View File

@ -18,6 +18,8 @@
#include <osg/Group>
#include <osg/Geometry>
#include <osg/MatrixTransform>
#include <osg/ClusterCullingCallback>
#include <osg/Notify>
#include <osgUtil/SmoothingVisitor>
#include <osgUtil/TriStripVisitor>
@ -1846,9 +1848,30 @@ osg::StateSet* DataSet::DestinationTile::createStateSet()
texture->setImage(image);
texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setMaxAnisotropy(8);
switch (_dataSet->getMipMappingMode())
{
case(DataSet::NO_MIP_MAPPING):
{
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
}
break;
case(DataSet::MIP_MAPPING_HARDWARE):
{
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
}
break;
case(DataSet::MIP_MAPPING_IMAGERY):
{
osg::notify(osg::NOTICE)<<"Mip mapped imagery not currently supported, falling back to hardware mip mapping."<<std::endl;
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
}
break;
}
texture->setMaxAnisotropy(_dataSet->getMaxAnisotropy());
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
bool inlineImageFile = _dataSet->getDestinationTileExtension()==".ive";
@ -2814,6 +2837,9 @@ DataSet::DataSet()
_databaseType = PagedLOD_DATABASE;
_geometryType = POLYGONAL;
_textureType = COMPRESSED_TEXTURE;
_maxAnisotropy = 1.0;
_mipMappingMode = MIP_MAPPING_HARDWARE;
_useLocalTileTransform = true;
_decorateWithCoordinateSystemNode = true;