From b6c4245b35ef419eb6563f7a6cc0e6dc608071d0 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Mon, 3 May 2021 16:45:47 +0100 Subject: [PATCH] WS30: Don't compress landclass textures Previously landclass textures were compressed by out internal optimizer. This caused bad artifacts on landclass boundaries, e.g. where landclass 1 met landclass 10 there would be compression/interpolation artifact with a value of (say) 5. This disables compression for such landclass textures. --- simgear/scene/model/ModelRegistry.cxx | 17 +++++++++++++---- simgear/scene/model/ModelRegistry.hxx | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 725d0bc4..12f768d7 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -656,7 +656,8 @@ OptimizeModelPolicy::OptimizeModelPolicy(const string& extension) : osg::Node* OptimizeModelPolicy::optimize(osg::Node* node, const string& fileName, - const osgDB::Options* opt) + const osgDB::Options* opt, + const bool compressTextures) { osgUtil::Optimizer optimizer; optimizer.optimize(node, _osgOptions); @@ -666,8 +667,11 @@ osg::Node* OptimizeModelPolicy::optimize(osg::Node* node, SGTexDataVarianceVisitor dataVarianceVisitor; node->accept(dataVarianceVisitor); - SGTexCompressionVisitor texComp; - node->accept(texComp); + if (compressTextures) { + SGTexCompressionVisitor texComp; + node->accept(texComp); + } + return node; } @@ -1065,9 +1069,14 @@ struct OSGOptimizePolicy : public OptimizeModelPolicy { terrain->addChild(optimized.get()); } } + + // We don't want any textures compressed, as these contain landclass information that doesn't + // interpolate well. + optimized = OptimizeModelPolicy::optimize(optimized, fileName, opt, false); + } else { + optimized = OptimizeModelPolicy::optimize(optimized, fileName, opt, true); } - optimized = OptimizeModelPolicy::optimize(optimized, fileName, opt); Group* group = dynamic_cast(optimized.get()); MatrixTransform* transform = dynamic_cast(optimized.get()); diff --git a/simgear/scene/model/ModelRegistry.hxx b/simgear/scene/model/ModelRegistry.hxx index 197bb197..a16e3870 100644 --- a/simgear/scene/model/ModelRegistry.hxx +++ b/simgear/scene/model/ModelRegistry.hxx @@ -151,7 +151,7 @@ class OptimizeModelPolicy { public: OptimizeModelPolicy(const std::string& extension); osg::Node* optimize(osg::Node* node, const std::string& fileName, - const osgDB::Options* opt); + const osgDB::Options* opt, const bool compressTextures=true); protected: unsigned _osgOptions; };