From ac6089a430b6a242eeab3f7dea0a45073b4a52ae Mon Sep 17 00:00:00 2001 From: cody glassman Date: Sat, 14 May 2022 23:06:32 -0700 Subject: [PATCH] skip flipping of 3D textures which is unsupported in OSG --- components/fx/technique.cpp | 2 +- components/resource/imagemanager.cpp | 5 +++-- components/resource/imagemanager.hpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/fx/technique.cpp b/components/fx/technique.cpp index 7ef3fb61a4..c186f12c0c 100644 --- a/components/fx/technique.cpp +++ b/components/fx/technique.cpp @@ -470,7 +470,7 @@ namespace fx else if (key == "source") { expect(); - auto image = mImageManager.getImage(std::string{std::get(mToken).value}); + auto image = mImageManager.getImage(std::string{std::get(mToken).value}, is3D); if constexpr (is1D) { type = Types::SamplerType::Texture_1D; diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index a544b7b621..ef90353a73 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -49,6 +49,7 @@ namespace Resource : ResourceManager(vfs) , mWarningImage(createWarningImage()) , mOptions(new osgDB::Options("dds_flip dds_dxt1_detect_rgba ignoreTga2Fields")) + , mOptionsNoFlip(new osgDB::Options("dds_dxt1_detect_rgba ignoreTga2Fields")) { } @@ -82,7 +83,7 @@ namespace Resource return true; } - osg::ref_ptr ImageManager::getImage(const std::string &filename) + osg::ref_ptr ImageManager::getImage(const std::string &filename, bool disableFlip) { const std::string normalized = mVFS->normalizeFilename(filename); @@ -135,7 +136,7 @@ namespace Resource stream->seekg(0); } - osgDB::ReaderWriter::ReadResult result = reader->readImage(*stream, mOptions); + osgDB::ReaderWriter::ReadResult result = reader->readImage(*stream, disableFlip ? mOptionsNoFlip : mOptions); if (!result.success()) { Log(Debug::Error) << "Error loading " << filename << ": " << result.message() << " code " << result.status(); diff --git a/components/resource/imagemanager.hpp b/components/resource/imagemanager.hpp index 64954af54b..85ea69795a 100644 --- a/components/resource/imagemanager.hpp +++ b/components/resource/imagemanager.hpp @@ -28,7 +28,7 @@ namespace Resource /// Create or retrieve an Image /// Returns the dummy image if the given image is not found. - osg::ref_ptr getImage(const std::string& filename); + osg::ref_ptr getImage(const std::string& filename, bool disableFlip = false); osg::Image* getWarningImage(); @@ -37,6 +37,7 @@ namespace Resource private: osg::ref_ptr mWarningImage; osg::ref_ptr mOptions; + osg::ref_ptr mOptionsNoFlip; ImageManager(const ImageManager&); void operator = (const ImageManager&);