Hi,

the discussions ended that it would be nice to have texture filtering a property which can be controlled by a commandline parameter. Experiments showed that not only runways, but scenery textures will profit very much.

Included are patches to SimGear, FlightGear and data (for help).

IMHO the result is amazing.

Compare the pics

http://www.oflebbe.de/oflebbe/FlightGear/filter822.png
with
http://www.oflebbe.de/oflebbe/FlightGear/filter122.png

For the first pic FlightGear is started with the additional parameter --texture-filtering=8

Please commit.
  Olaf


Index: src/Main/options.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/Main/options.cxx,v
retrieving revision 1.94
diff -u -r1.94 options.cxx
--- src/Main/options.cxx        5 May 2007 09:58:40 -0000       1.94
+++ src/Main/options.cxx        14 May 2007 20:35:04 -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);
@@ -1326,6 +1329,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: simgear/scene/material/mat.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/material/mat.cxx,v
retrieving revision 1.37
diff -u -r1.37 mat.cxx
--- simgear/scene/material/mat.cxx      13 May 2007 11:53:06 -0000      1.37
+++ simgear/scene/material/mat.cxx      14 May 2007 20:37:52 -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;
        }
     }
@@ -282,7 +281,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;
@@ -319,7 +318,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);
@@ -327,7 +326,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;
    }
@@ -362,5 +361,15 @@
 {
 }
 
+////////////////////////////////////////////////////////////////////////
+// SGTextureFilterListener
+////////////////////////////////////////////////////////////////////////
+
+
+int SGTextureFilterListener::filter = 1;
 
+int SGTextureFilterListener::getFilter() { return filter; };
+void SGTextureFilterListener::setFilter(int filt) { 
+    filter = filt;
+};
 // 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.27
diff -u -r1.27 mat.hxx
--- simgear/scene/material/mat.hxx      13 May 2007 11:53:06 -0000      1.27
+++ simgear/scene/material/mat.hxx      14 May 2007 20:37:53 -0000
@@ -53,6 +53,17 @@
 
 class SGMaterialGlyph;
 
+class SGTextureFilterListener  {
+private:
+  static int filter;
+
+  SGTextureFilterListener() {
+  }
+  
+public:
+  static int getFilter();
+  static void setFilter(int filt);
+ };
 
 /**
  * A material in the scene graph.
@@ -121,7 +132,6 @@
    */
   bool load_texture (int n = -1);
 
-
   /**
    * Get the textured state.
    */
@@ -252,9 +262,6 @@
   // use mipmapping?
   int mipmap;
 
-  // use anisotropic filtering
-  float filtering;
-
   // coverage of night lighting.
   double light_coverage;
 
@@ -296,7 +303,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: Translations/strings-default.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Translations/strings-default.xml,v
retrieving revision 1.32
diff -u -r1.32 strings-default.xml
--- Translations/strings-default.xml    5 May 2007 09:55:40 -0000       1.32
+++ Translations/strings-default.xml    14 May 2007 20:59:31 -0000
@@ -202,6 +202,7 @@
  <enable-skyblend-desc>Enable sky blending</enable-skyblend-desc>
  <disable-textures-desc>Disable textures</disable-textures-desc>
  <enable-textures-desc>Enable textures</enable-textures-desc>
+ <texture-filtering-desc>Anisotropic Texture Filtering: values should be 1 
(default),2,4,8 or 16</texture-filtering-desc>
  <disable-wireframe-desc>Disable wireframe drawing 
mode</disable-wireframe-desc>
  <enable-wireframe-desc>Enable wireframe drawing mode</enable-wireframe-desc>
  <geometry-desc>Specify window geometry (640x480, etc)</geometry-desc>
Index: options.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/options.xml,v
retrieving revision 1.44
diff -u -r1.44 options.xml
--- options.xml 5 May 2007 09:51:41 -0000       1.44
+++ options.xml 14 May 2007 20:59:33 -0000
@@ -404,6 +404,12 @@
    </option>
 
    <option>
+    <name>texture-filtering</name>
+    <arg>value</arg>
+    <description>strings/texture-filtering-desc</description>
+   </option>
+
+   <option>
     <name>disable-wireframe</name>
     <description>strings/disable-wireframe-desc</description>
    </option>
-------------------------------------------------------------------------
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
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to