Hi,I had the chance to get a small lecture on OSG. I tried out anisotropic filtering for improving the look of the runways. IMHO the result is amazing.
Compare yourself -- have a look the markings on the runway: http://www.oflebbe.de/oflebbe/FlightGear/withoutfilter.jpg http://www.oflebbe.de/oflebbe/FlightGear/with8filter.jpg Without any drop in framerate ... Filtering can be switch on and controlled as per SGMaterial. 1. == default off Please note that only powers of two are valid. Cheers olaf
Index: simgear/scene/material/mat.cxx =================================================================== RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/material/mat.cxx,v retrieving revision 1.34 diff -u -r1.34 mat.cxx --- simgear/scene/material/mat.cxx 3 Dec 2006 17:27:46 -0000 1.34 +++ simgear/scene/material/mat.cxx 20 Apr 2007 20:59:00 -0000 @@ -141,6 +141,7 @@ 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 @@ -204,6 +205,7 @@ wrapv = true; mipmap = true; + filtering = 1.0f; light_coverage = 0.0; solid = true; @@ -233,7 +235,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 ); + wrapu, wrapv, mipmap, filtering ); _status[i].texture_loaded = true; } } @@ -279,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 ); + assignTexture( stateSet, _status[i].texture_path, wrapu, wrapv, 1, filtering ); _status[i].texture_loaded = true; } else { _status[i].texture_loaded = false; @@ -316,7 +318,7 @@ } void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname, - int _wrapu, int _wrapv, int _mipmap ) + int _wrapu, int _wrapv, int _mipmap, float filtering ) { map<string, osg::ref_ptr<osg::Texture2D> >::iterator _tex_cache_iter; _tex_cache_iter = _tex_cache.find(fname); @@ -324,6 +326,7 @@ { osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv, mipmap ? -1 : 0); + texture->setMaxAnisotropy( filtering); state->setTextureAttributeAndModes(0, texture); _tex_cache[fname] = texture; } Index: simgear/scene/material/mat.hxx =================================================================== RCS file: /var/cvs/SimGear-0.3/SimGear/simgear/scene/material/mat.hxx,v retrieving revision 1.25 diff -u -r1.25 mat.hxx --- simgear/scene/material/mat.hxx 29 Oct 2006 19:27:09 -0000 1.25 +++ simgear/scene/material/mat.hxx 20 Apr 2007 20:59:01 -0000 @@ -252,6 +252,9 @@ // use mipmapping? int mipmap; + // use anisotropic filtering + float filtering; + // coverage of night lighting. double light_coverage; @@ -293,7 +296,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 ); + void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE, float filtering = 1.0f ); };
Index: materials.xml =================================================================== RCS file: /var/cvs/FlightGear-0.9/data/materials.xml,v retrieving revision 1.88 diff -u -r1.88 materials.xml --- materials.xml 28 Jan 2007 11:43:50 -0000 1.88 +++ materials.xml 20 Apr 2007 21:13:40 -0000 @@ -126,29 +126,34 @@ <material> <name>pa_taxiway</name> <texture>Runway/pa_taxiway.rgb</texture> + <filtering>8.</filtering> </material> <material> <name>pa_tiedown</name> <texture>Runway/pa_tiedown.rgb</texture> + <filtering>8.</filtering> </material> <material> <name>pa_dspl_thresh</name> <texture>Runway/pa_dspl_thresh.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_dspl_arrows</name> <texture>Runway/pa_dspl_arrows.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_threshold</name> <texture>Runway/pa_threshold.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> <wrapv>false</wrapv> </material> @@ -156,234 +161,273 @@ <name>pa_L</name> <texture>Runway/pa_L.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_R</name> <texture>Runway/pa_R.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_C</name> <texture>Runway/pa_C.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_0l</name> <texture>Runway/pa_0l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_0r</name> <texture>Runway/pa_0r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_1c</name> <texture>Runway/pa_1c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_1l</name> <texture>Runway/pa_1l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_1r</name> <texture>Runway/pa_1r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_11</name> <texture>Runway/pa_11.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_2c</name> <texture>Runway/pa_2c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_2l</name> <texture>Runway/pa_2l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_2r</name> <texture>Runway/pa_2r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_3c</name> <texture>Runway/pa_3c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_3l</name> <texture>Runway/pa_3l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_3r</name> <texture>Runway/pa_3r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_4c</name> <texture>Runway/pa_4c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_4r</name> <texture>Runway/pa_4r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_5c</name> <texture>Runway/pa_5c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_5r</name> <texture>Runway/pa_5r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_6c</name> <texture>Runway/pa_6c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_6r</name> <texture>Runway/pa_6r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_7c</name> <texture>Runway/pa_7c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_7r</name> <texture>Runway/pa_7r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_8c</name> <texture>Runway/pa_8c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_8r</name> <texture>Runway/pa_8r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_9c</name> <texture>Runway/pa_9c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_9r</name> <texture>Runway/pa_9r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_tz_three</name> <texture>Runway/pa_tz_three.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_aim</name> <texture>Runway/pa_aim.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_tz_two_a</name> <texture>Runway/pa_tz_two_a.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_tz_two_b</name> <texture>Runway/pa_tz_two_b.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_tz_one_a</name> <texture>Runway/pa_tz_one_a.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_tz_one_b</name> <texture>Runway/pa_tz_one_b.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_centerline</name> <texture>Runway/pa_centerline.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pa_rest</name> <texture>Runway/pa_rest.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pc_taxiway</name> <name>dirt_rwytaxiway</name> <texture>Runway/pc_taxiway.rgb</texture> + <filtering>8.</filtering> </material> <material> <name>pc_tiedown</name> <name>dirt_rwytiedown</name> <texture>Runway/pc_tiedown.rgb</texture> + <filtering>8.</filtering> </material> <material> <name>pc_dspl_thresh</name> <texture>Runway/pc_dspl_thresh.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> <name>pc_dspl_arrows</name> <texture>Runway/pc_dspl_arrows.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -392,6 +436,7 @@ <texture>Runway/pc_threshold.rgb</texture> <wrapu>false</wrapu> <wrapv>false</wrapv> + <filtering>8.</filtering> </material> <material> @@ -399,6 +444,7 @@ <name>dirt_rwyL</name> <texture>Runway/pc_L.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -406,6 +452,7 @@ <name>dirt_rwyR</name> <texture>Runway/pc_R.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -413,6 +460,7 @@ <name>dirt_rwyC</name> <texture>Runway/pc_C.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -420,6 +468,7 @@ <name>dirt_rwy0l</name> <texture>Runway/pc_0l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -427,6 +476,7 @@ <name>dirt_rwy0r</name> <texture>Runway/pc_0r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -434,6 +484,7 @@ <name>dirt_rwy1c</name> <texture>Runway/pc_1c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -441,6 +492,7 @@ <name>dirt_rwy1l</name> <texture>Runway/pc_1l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -448,6 +500,7 @@ <name>dirt_rwy1r</name> <texture>Runway/pc_1r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -455,6 +508,7 @@ <name>dirt_rwy11</name> <texture>Runway/pc_11.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -462,6 +516,7 @@ <name>dirt_rwy2c</name> <texture>Runway/pc_2c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -469,6 +524,7 @@ <name>dirt_rwy2l</name> <texture>Runway/pc_2l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -476,6 +532,7 @@ <name>dirt_rwy2r</name> <texture>Runway/pc_2r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -483,6 +540,7 @@ <name>dirt_rwy3c</name> <texture>Runway/pc_3c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -490,6 +548,7 @@ <name>dirt_rwy3l</name> <texture>Runway/pc_3l.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -504,6 +563,7 @@ <name>dirt_rwy4c</name> <texture>Runway/pc_4c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -511,6 +571,7 @@ <name>dirt_rwy4r</name> <texture>Runway/pc_4r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -518,6 +579,7 @@ <name>dirt_rwy5c</name> <texture>Runway/pc_5c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -525,6 +587,7 @@ <name>dirt_rwy5r</name> <texture>Runway/pc_5r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -532,6 +595,7 @@ <name>dirt_rwy6c</name> <texture>Runway/pc_6c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -539,6 +603,7 @@ <name>dirt_rwy6r</name> <texture>Runway/pc_6r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -546,6 +611,7 @@ <name>dirt_rwy7c</name> <texture>Runway/pc_7c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -553,6 +619,7 @@ <name>dirt_rwy7r</name> <texture>Runway/pc_7r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -560,6 +627,7 @@ <name>dirt_rwy8c</name> <texture>Runway/pc_8c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -567,6 +635,7 @@ <name>dirt_rwy8r</name> <texture>Runway/pc_8r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -574,6 +643,7 @@ <name>dirt_rwy9c</name> <texture>Runway/pc_9c.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -581,6 +651,7 @@ <name>dirt_rwy9r</name> <texture>Runway/pc_9r.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -588,6 +659,7 @@ <name>dirt_rwytz_three</name> <texture>Runway/pc_tz_three.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -595,6 +667,7 @@ <name>dirt_rwyaim</name> <texture>Runway/pc_aim.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -602,6 +675,7 @@ <name>dirt_rwytz_two_a</name> <texture>Runway/pc_tz_two_a.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -609,6 +683,7 @@ <name>dirt_rwytz_two_b</name> <texture>Runway/pc_tz_two_b.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -616,6 +691,7 @@ <name>dirt_rwytz_one_a</name> <texture>Runway/pc_tz_one_a.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -623,6 +699,7 @@ <name>dirt_rwytz_one_b</name> <texture>Runway/pc_tz_one_b.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -630,6 +707,7 @@ <name>dirt_rwycenterline</name> <texture>Runway/pc_centerline.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <material> @@ -637,6 +715,7 @@ <name>dirt_rwyrest</name> <texture>Runway/pc_rest.rgb</texture> <wrapu>false</wrapu> + <filtering>8.</filtering> </material> <!-- Default --> Index: materials.dtd =================================================================== RCS file: /var/cvs/FlightGear-0.9/data/materials.dtd,v retrieving revision 1.1 diff -u -r1.1 materials.dtd --- materials.dtd 28 Dec 2001 22:37:57 -0000 1.1 +++ materials.dtd 20 Apr 2007 21:13:54 -0000 @@ -10,7 +10,8 @@ <!ENTITY % colours "r?, g?, b?, a?"> <!ELEMENT PropertyList (material+)> -<!ELEMENT material (name+, texture, wrapu?, wrapv?, mipmap?, xsize?, ysize?, +<!ELEMENT material (name+, texture, wrapu?, wrapv?, mipmap?, filtering?, + xsize?, ysize?, light-coverage?, ambient?, diffuse?, specular?, emissive?)> <!ELEMENT name (#PCDATA)> <!ELEMENT texture (#PCDATA)>
------------------------------------------------------------------------- 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