Hi,
changed the patch, texture filtering is now a global property, since
rendering of landscape textures can be dramatically improved by
anisotropic filtering.
There is a command switch --texture-filtering={1,2,4,8,16} and the
rendering options panel contains a selector changing the whole scene at
once.
Have fun,
Olaf
PS: texture bleeding on models is not influenced in any way by these
switches.
Index: gui/dialogs/rendering.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/gui/dialogs/rendering.xml,v
retrieving revision 1.24
diff -u -r1.24 rendering.xml
--- gui/dialogs/rendering.xml 26 Mar 2007 15:25:27 -0000 1.24
+++ gui/dialogs/rendering.xml 30 Apr 2007 20:30:39 -0000
@@ -78,6 +78,25 @@
</binding>
</checkbox>
+ <group>
+ <layout>hbox</layout>
+ <halign>left</halign>
+ <text>
+ <label>Anisotropic filtering</label>
+ </text>
+ <combo>
+ <property>/sim/rendering/filtering</property>
+ <value>1</value>
+ <value>2</value>
+ <value>4</value>
+ <value>8</value>
+ <value>16</value>
+ <binding>
+ <command>dialog-apply</command>
+ </binding>
+ </combo>
+ </group>
+
<checkbox>
<halign>left</halign>
<label>Precipitation</label>
Index: simgear/scene/material/mat.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/material/mat.cxx,v
retrieving revision 1.35
diff -u -r1.35 mat.cxx
--- simgear/scene/material/mat.cxx 21 Apr 2007 12:13:16 -0000 1.35
+++ simgear/scene/material/mat.cxx 30 Apr 2007 20:20:15 -0000
@@ -49,6 +49,7 @@
#include <simgear/misc/sgstream.hxx>
#include <simgear/scene/model/model.hxx>
+
#include "mat.hxx"
static map<string, osg::ref_ptr<osg::Texture2D> > _tex_cache;
@@ -141,7 +142,6 @@
wrapu = props->getBoolValue("wrapu", true);
wrapv = props->getBoolValue("wrapv", true);
mipmap = props->getBoolValue("mipmap", true);
- filtering = props->getDoubleValue("filtering", 1.0);
light_coverage = props->getDoubleValue("light-coverage", 0.0);
// surface values for use with ground reactions
@@ -205,7 +205,6 @@
wrapv = true;
mipmap = true;
- filtering = 1.0f;
light_coverage = 0.0;
solid = true;
@@ -235,7 +234,7 @@
SG_LOG( SG_GENERAL, SG_INFO, "Loading deferred texture "
<< _status[i].texture_path );
assignTexture(_status[i].state.get(), _status[i].texture_path,
- wrapu, wrapv, mipmap, filtering );
+ wrapu, wrapv, mipmap);
_status[i].texture_loaded = true;
}
}
@@ -281,7 +280,7 @@
if ( !defer_tex_load ) {
SG_LOG(SG_INPUT, SG_INFO, " " << _status[i].texture_path );
- assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv, 1,
filtering );
+ assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv);
_status[i].texture_loaded = true;
} else {
_status[i].texture_loaded = false;
@@ -318,7 +317,7 @@
}
void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname,
- int _wrapu, int _wrapv, int _mipmap, float filtering )
+ int _wrapu, int _wrapv, int _mipmap )
{
map<string, osg::ref_ptr<osg::Texture2D> >::iterator _tex_cache_iter;
_tex_cache_iter = _tex_cache.find(fname);
@@ -326,7 +325,7 @@
{
osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv,
mipmap ? -1 : 0);
- texture->setMaxAnisotropy( filtering);
+ texture->setMaxAnisotropy( SGTextureFilterListener::getFilter());
state->setTextureAttributeAndModes(0, texture);
_tex_cache[fname] = texture;
}
@@ -361,5 +360,43 @@
{
}
+////////////////////////////////////////////////////////////////////////
+// SGTextureFilterListener
+////////////////////////////////////////////////////////////////////////
+
+
+
+void SGTexFilterVisitor::apply(int, osg::StateSet::RefAttributePair& refAttr)
+{
+ osg::Texture2D* texture;
+ texture = dynamic_cast<osg::Texture2D*>(refAttr.first.get());
+ if (!texture)
+ return;
+
+ texture->setMaxAnisotropy( filter);
+};
+osg::ref_ptr<osg::Group> SGTextureFilterListener::root;
+
+void
+SGTextureFilterListener::valueChanged( SGPropertyNode *node) {
+ float filter = node->getIntValue();
+ SGTexFilterVisitor texVisit( filter) ;
+ root->accept( texVisit);
+}
+
+SGTextureFilterListener *SGTextureFilterListener::obj = NULL;
+int SGTextureFilterListener::filter = 1;
+
+int SGTextureFilterListener::getFilter() { return filter; };
+void SGTextureFilterListener::setFilter(int filt) {
+ filter = filt;
+ if (root != NULL) {
+ SGTexFilterVisitor texVisit( filter) ;
+ root->accept( texVisit);
+ }
+};
+void SGTextureFilterListener::setRoot( osg::ref_ptr<osg::Group> r) {
+ root = r;
+}
// end of mat.cxx
Index: simgear/scene/material/mat.hxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/material/mat.hxx,v
retrieving revision 1.26
diff -u -r1.26 mat.hxx
--- simgear/scene/material/mat.hxx 21 Apr 2007 12:13:16 -0000 1.26
+++ simgear/scene/material/mat.hxx 30 Apr 2007 20:20:16 -0000
@@ -43,6 +43,7 @@
#include <simgear/props/props.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
+#include <simgear/scene/util/SGTextureStateAttributeVisitor.hxx>
#include "matmodel.hxx"
@@ -53,6 +54,40 @@
class SGMaterialGlyph;
+class SGTexFilterVisitor : public SGTextureStateAttributeVisitor {
+
+public:
+ SGTexFilterVisitor(float Filter) : filter( Filter) {
+ }
+
+ virtual void apply(int, osg::StateSet::RefAttributePair& refAttr);
+
+private:
+ float filter;
+};
+
+
+
+class SGTextureFilterListener : public SGPropertyChangeListener {
+private:
+ static int filter;
+ static osg::ref_ptr<osg::Group> root;
+ static SGTextureFilterListener *obj;
+ SGTextureFilterListener() {
+ }
+
+public:
+ static SGTextureFilterListener *GetSGTextureFilterListener() {
+ if (!obj)
+ obj = new SGTextureFilterListener;
+ return obj;
+ }
+
+ virtual void valueChanged (SGPropertyNode * node);
+ static int getFilter();
+ static void setFilter(int filt);
+ static void setRoot( osg::ref_ptr<osg::Group> r);
+ };
/**
* A material in the scene graph.
@@ -121,7 +156,6 @@
*/
bool load_texture (int n = -1);
-
/**
* Get the textured state.
*/
@@ -252,9 +286,6 @@
// use mipmapping?
int mipmap;
- // use anisotropic filtering
- float filtering;
-
// coverage of night lighting.
double light_coverage;
@@ -296,7 +327,7 @@
void build_state( bool defer_tex_load );
void set_state( osg::StateSet *s );
- void assignTexture( osg::StateSet *state, const std::string &fname, int
_wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE, float filtering = 1.0f );
+ void assignTexture( osg::StateSet *state, const std::string &fname, int
_wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE );
};
Index: src/Main/options.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/options.cxx,v
retrieving revision 1.92
diff -u -r1.92 options.cxx
--- src/Main/options.cxx 3 Jan 2007 10:51:54 -0000 1.92
+++ src/Main/options.cxx 30 Apr 2007 20:26:51 -0000
@@ -42,6 +42,7 @@
#include <simgear/math/sg_random.h>
#include <simgear/misc/sgstream.hxx>
#include <simgear/misc/sg_path.hxx>
+#include <simgear/scene/material/mat.hxx>
// #include <Include/general.hxx>
// #include <Airports/simple.hxx>
@@ -204,6 +205,8 @@
fgSetBool("/sim/rendering/shading", true);
fgSetBool("/sim/rendering/skyblend", true);
fgSetBool("/sim/rendering/textures", true);
+ fgTie( "/sim/rendering/filtering", SGTextureFilterListener::getFilter,
SGTextureFilterListener::setFilter, false);
+ fgSetInt("/sim/rendering/filtering", 1);
fgSetBool("/sim/rendering/wireframe", false);
fgSetBool("/sim/rendering/horizon-effect", false);
fgSetBool("/sim/rendering/enhanced-lighting", false);
@@ -1330,6 +1333,7 @@
{"enable-skyblend", false, OPTION_BOOL,
"/sim/rendering/skyblend", true, "", 0 },
{"disable-textures", false, OPTION_BOOL,
"/sim/rendering/textures", false, "", 0 },
{"enable-textures", false, OPTION_BOOL,
"/sim/rendering/textures", true, "", 0 },
+ {"texture-filtering", false, OPTION_INT,
"/sim/rendering/filtering", 1, "", 0 },
{"disable-wireframe", false, OPTION_BOOL,
"/sim/rendering/wireframe", false, "", 0 },
{"enable-wireframe", false, OPTION_BOOL,
"/sim/rendering/wireframe", true, "", 0 },
{"geometry", true, OPTION_FUNC, "", false, "",
fgOptGeometry },
Index: src/Main/renderer.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/renderer.cxx,v
retrieving revision 1.78
diff -u -r1.78 renderer.cxx
--- src/Main/renderer.cxx 7 Apr 2007 09:54:18 -0000 1.78
+++ src/Main/renderer.cxx 30 Apr 2007 20:26:54 -0000
@@ -62,6 +62,7 @@
#include <simgear/math/SGMath.hxx>
#include <simgear/screen/extensions.hxx>
+#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/animation.hxx>
#include <simgear/scene/model/model.hxx>
@@ -363,6 +364,8 @@
#ifdef FG_JPEG_SERVER
jpgRenderFrame = NULL;
#endif
+sceneView = 0;
+
}
// Initialize various GL/view parameters
@@ -389,6 +392,9 @@
glHint ( GL_FOG_HINT, GL_DONT_CARE );
}
+
+ SGTextureFilterListener::setRoot( mRoot);
+
glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glHint(GL_POINT_SMOOTH_HINT, GL_DONT_CARE);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel