Use normalized path in ImageManager

pull/3236/head
elsid 4 months ago
parent b9cb028809
commit 1fd6ac6438
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -176,14 +176,14 @@ namespace CSVRender
mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(Alpha, RenderBin)); mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(Alpha, RenderBin));
// Add water texture // Add water texture
std::string textureName = "textures/water/"; constexpr VFS::Path::NormalizedView prefix("textures/water");
textureName += Fallback::Map::getString("Water_SurfaceTexture"); VFS::Path::Normalized texturePath(prefix);
textureName += "00.dds"; texturePath /= std::string(Fallback::Map::getString("Water_SurfaceTexture")) + "00.dds";
Resource::ImageManager* imageManager = mData.getResourceSystem()->getImageManager(); Resource::ImageManager* imageManager = mData.getResourceSystem()->getImageManager();
osg::ref_ptr<osg::Texture2D> waterTexture = new osg::Texture2D(); osg::ref_ptr<osg::Texture2D> waterTexture = new osg::Texture2D();
waterTexture->setImage(imageManager->getImage(textureName)); waterTexture->setImage(imageManager->getImage(texturePath));
waterTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); waterTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
waterTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); waterTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);

@ -2229,9 +2229,10 @@ namespace MWGui
ResourceImageSetPointerFix* imgSetPointer = resource->castType<ResourceImageSetPointerFix>(false); ResourceImageSetPointerFix* imgSetPointer = resource->castType<ResourceImageSetPointerFix>(false);
if (!imgSetPointer) if (!imgSetPointer)
continue; continue;
auto tex_name = imgSetPointer->getImageSet()->getIndexInfo(0, 0).texture;
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(tex_name); const VFS::Path::Normalized path(imgSetPointer->getImageSet()->getIndexInfo(0, 0).texture);
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(path);
if (image.valid()) if (image.valid())
{ {

@ -41,8 +41,8 @@ namespace
{ {
std::ostringstream texname; std::ostringstream texname;
texname << "textures/water/" << tex << std::setw(2) << std::setfill('0') << i << ".dds"; texname << "textures/water/" << tex << std::setw(2) << std::setfill('0') << i << ".dds";
osg::ref_ptr<osg::Texture2D> tex2( const VFS::Path::Normalized path(texname.str());
new osg::Texture2D(resourceSystem->getImageManager()->getImage(texname.str()))); osg::ref_ptr<osg::Texture2D> tex2(new osg::Texture2D(resourceSystem->getImageManager()->getImage(path)));
tex2->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); tex2->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
tex2->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); tex2->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
resourceSystem->getSceneManager()->applyFilterSettings(tex2); resourceSystem->getSceneManager()->applyFilterSettings(tex2);

@ -403,8 +403,9 @@ namespace MWRender
osg::ref_ptr<osg::StateSet> stateset = mRainParticleSystem->getOrCreateStateSet(); osg::ref_ptr<osg::StateSet> stateset = mRainParticleSystem->getOrCreateStateSet();
constexpr VFS::Path::NormalizedView raindropImage("textures/tx_raindrop_01.dds");
osg::ref_ptr<osg::Texture2D> raindropTex osg::ref_ptr<osg::Texture2D> raindropTex
= new osg::Texture2D(mSceneManager->getImageManager()->getImage("textures/tx_raindrop_01.dds")); = new osg::Texture2D(mSceneManager->getImageManager()->getImage(raindropImage));
raindropTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); raindropTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
raindropTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); raindropTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
@ -768,7 +769,8 @@ namespace MWRender
{ {
mClouds = weather.mCloudTexture; mClouds = weather.mCloudTexture;
std::string texture = Misc::ResourceHelpers::correctTexturePath(mClouds, mSceneManager->getVFS()); const VFS::Path::Normalized texture
= Misc::ResourceHelpers::correctTexturePath(mClouds, mSceneManager->getVFS());
osg::ref_ptr<osg::Texture2D> cloudTex osg::ref_ptr<osg::Texture2D> cloudTex
= new osg::Texture2D(mSceneManager->getImageManager()->getImage(texture)); = new osg::Texture2D(mSceneManager->getImageManager()->getImage(texture));
@ -790,7 +792,8 @@ namespace MWRender
if (!mNextClouds.empty()) if (!mNextClouds.empty())
{ {
std::string texture = Misc::ResourceHelpers::correctTexturePath(mNextClouds, mSceneManager->getVFS()); const VFS::Path::Normalized texture
= Misc::ResourceHelpers::correctTexturePath(mNextClouds, mSceneManager->getVFS());
osg::ref_ptr<osg::Texture2D> cloudTex osg::ref_ptr<osg::Texture2D> cloudTex
= new osg::Texture2D(mSceneManager->getImageManager()->getImage(texture)); = new osg::Texture2D(mSceneManager->getImageManager()->getImage(texture));

@ -406,7 +406,7 @@ namespace MWRender
} }
} }
void setTextures(const std::string& phaseTex, const std::string& circleTex) void setTextures(VFS::Path::NormalizedView phaseTex, VFS::Path::NormalizedView circleTex)
{ {
mPhaseTex = new osg::Texture2D(mImageManager.getImage(phaseTex)); mPhaseTex = new osg::Texture2D(mImageManager.getImage(phaseTex));
mPhaseTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); mPhaseTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
@ -766,7 +766,9 @@ namespace MWRender
Resource::ImageManager& imageManager = *sceneManager.getImageManager(); Resource::ImageManager& imageManager = *sceneManager.getImageManager();
osg::ref_ptr<osg::Texture2D> sunTex = new osg::Texture2D(imageManager.getImage("textures/tx_sun_05.dds")); constexpr VFS::Path::NormalizedView image("textures/tx_sun_05.dds");
osg::ref_ptr<osg::Texture2D> sunTex = new osg::Texture2D(imageManager.getImage(image));
sunTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); sunTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
sunTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); sunTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
@ -907,8 +909,8 @@ namespace MWRender
void Sun::createSunFlash(Resource::ImageManager& imageManager) void Sun::createSunFlash(Resource::ImageManager& imageManager)
{ {
osg::ref_ptr<osg::Texture2D> tex constexpr VFS::Path::NormalizedView image("textures/tx_sun_flash_grey_05.dds");
= new osg::Texture2D(imageManager.getImage("textures/tx_sun_flash_grey_05.dds")); osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D(imageManager.getImage(image));
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
@ -1115,10 +1117,18 @@ namespace MWRender
textureName += ".dds"; textureName += ".dds";
const VFS::Path::Normalized texturePath(std::move(textureName));
if (mType == Moon::Type_Secunda) if (mType == Moon::Type_Secunda)
mUpdater->setTextures(textureName, "textures/tx_mooncircle_full_s.dds"); {
constexpr VFS::Path::NormalizedView secunda("textures/tx_mooncircle_full_s.dds");
mUpdater->setTextures(texturePath, secunda);
}
else else
mUpdater->setTextures(textureName, "textures/tx_mooncircle_full_m.dds"); {
constexpr VFS::Path::NormalizedView masser("textures/tx_mooncircle_full_m.dds");
mUpdater->setTextures(texturePath, masser);
}
} }
int RainCounter::numParticlesToCreate(double dt) const int RainCounter::numParticlesToCreate(double dt) const

@ -49,7 +49,8 @@ namespace MWRender
{ {
if (texture.empty()) if (texture.empty())
return; return;
std::string correctedTexture = Misc::ResourceHelpers::correctTexturePath(texture, resourceSystem->getVFS()); const VFS::Path::Normalized correctedTexture
= Misc::ResourceHelpers::correctTexturePath(texture, resourceSystem->getVFS());
// Not sure if wrap settings should be pulled from the overridden texture? // Not sure if wrap settings should be pulled from the overridden texture?
osg::ref_ptr<osg::Texture2D> tex osg::ref_ptr<osg::Texture2D> tex
= new osg::Texture2D(resourceSystem->getImageManager()->getImage(correctedTexture)); = new osg::Texture2D(resourceSystem->getImageManager()->getImage(correctedTexture));

@ -589,8 +589,8 @@ namespace MWRender
{ {
std::ostringstream texname; std::ostringstream texname;
texname << "textures/water/" << texture << std::setw(2) << std::setfill('0') << i << ".dds"; texname << "textures/water/" << texture << std::setw(2) << std::setfill('0') << i << ".dds";
osg::ref_ptr<osg::Texture2D> tex( const VFS::Path::Normalized path(texname.str());
new osg::Texture2D(mResourceSystem->getImageManager()->getImage(texname.str()))); osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(mResourceSystem->getImageManager()->getImage(path)));
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
mResourceSystem->getSceneManager()->applyFilterSettings(tex); mResourceSystem->getSceneManager()->applyFilterSettings(tex);
@ -703,8 +703,9 @@ namespace MWRender
Shader::ShaderManager& shaderMgr = mResourceSystem->getSceneManager()->getShaderManager(); Shader::ShaderManager& shaderMgr = mResourceSystem->getSceneManager()->getShaderManager();
osg::ref_ptr<osg::Program> program = shaderMgr.getProgram("water", defineMap); osg::ref_ptr<osg::Program> program = shaderMgr.getProgram("water", defineMap);
constexpr VFS::Path::NormalizedView waterImage("textures/omw/water_nm.png");
osg::ref_ptr<osg::Texture2D> normalMap( osg::ref_ptr<osg::Texture2D> normalMap(
new osg::Texture2D(mResourceSystem->getImageManager()->getImage("textures/omw/water_nm.png"))); new osg::Texture2D(mResourceSystem->getImageManager()->getImage(waterImage)));
normalMap->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); normalMap->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
normalMap->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); normalMap->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
mResourceSystem->getSceneManager()->applyFilterSettings(normalMap); mResourceSystem->getSceneManager()->applyFilterSettings(normalMap);

@ -445,7 +445,8 @@ namespace fx
else if (key == "source") else if (key == "source")
{ {
expect<Lexer::String>(); expect<Lexer::String>();
auto image = mImageManager.getImage(std::string{ std::get<Lexer::String>(mToken).value }, is3D); const osg::ref_ptr<osg::Image> image
= mImageManager.getImage(VFS::Path::Normalized(std::get<Lexer::String>(mToken).value), is3D);
if constexpr (is1D) if constexpr (is1D)
{ {
type = Types::SamplerType::Texture_1D; type = Types::SamplerType::Texture_1D;

@ -95,7 +95,7 @@ namespace osgMyGUI
if (!mImageManager) if (!mImageManager)
throw std::runtime_error("No imagemanager set"); throw std::runtime_error("No imagemanager set");
osg::ref_ptr<osg::Image> image(mImageManager->getImage(fname)); osg::ref_ptr<osg::Image> image(mImageManager->getImage(VFS::Path::toNormalized(fname)));
mTexture = new osg::Texture2D(image); mTexture = new osg::Texture2D(image);
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); mTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);

@ -1022,8 +1022,8 @@ namespace NifOsg
if (!mImageManager) if (!mImageManager)
return nullptr; return nullptr;
std::string filename = Misc::ResourceHelpers::correctTexturePath(path, mImageManager->getVFS()); return mImageManager->getImage(
return mImageManager->getImage(filename); VFS::Path::toNormalized(Misc::ResourceHelpers::correctTexturePath(path, mImageManager->getVFS())));
} }
osg::ref_ptr<osg::Texture2D> attachTexture(const std::string& name, osg::ref_ptr<osg::Image> image, bool wrapS, osg::ref_ptr<osg::Texture2D> attachTexture(const std::string& name, osg::ref_ptr<osg::Image> image, bool wrapS,

@ -85,11 +85,9 @@ namespace Resource
return true; return true;
} }
osg::ref_ptr<osg::Image> ImageManager::getImage(std::string_view filename, bool disableFlip) osg::ref_ptr<osg::Image> ImageManager::getImage(VFS::Path::NormalizedView path, bool disableFlip)
{ {
const std::string normalized = VFS::Path::normalizeFilename(filename); osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(path);
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(normalized);
if (obj) if (obj)
return osg::ref_ptr<osg::Image>(static_cast<osg::Image*>(obj.get())); return osg::ref_ptr<osg::Image>(static_cast<osg::Image*>(obj.get()));
else else
@ -97,21 +95,21 @@ namespace Resource
Files::IStreamPtr stream; Files::IStreamPtr stream;
try try
{ {
stream = mVFS->get(normalized); stream = mVFS->get(path);
} }
catch (std::exception& e) catch (std::exception& e)
{ {
Log(Debug::Error) << "Failed to open image: " << e.what(); Log(Debug::Error) << "Failed to open image: " << e.what();
mCache->addEntryToObjectCache(normalized, mWarningImage); mCache->addEntryToObjectCache(path.value(), mWarningImage);
return mWarningImage; return mWarningImage;
} }
const std::string ext(Misc::getFileExtension(normalized)); const std::string ext(Misc::getFileExtension(path.value()));
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(ext); osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(ext);
if (!reader) if (!reader)
{ {
Log(Debug::Error) << "Error loading " << filename << ": no readerwriter for '" << ext << "' found"; Log(Debug::Error) << "Error loading " << path << ": no readerwriter for '" << ext << "' found";
mCache->addEntryToObjectCache(normalized, mWarningImage); mCache->addEntryToObjectCache(path.value(), mWarningImage);
return mWarningImage; return mWarningImage;
} }
@ -123,8 +121,8 @@ namespace Resource
stream->read((char*)header, 18); stream->read((char*)header, 18);
if (stream->gcount() != 18) if (stream->gcount() != 18)
{ {
Log(Debug::Error) << "Error loading " << filename << ": couldn't read TGA header"; Log(Debug::Error) << "Error loading " << path << ": couldn't read TGA header";
mCache->addEntryToObjectCache(normalized, mWarningImage); mCache->addEntryToObjectCache(path.value(), mWarningImage);
return mWarningImage; return mWarningImage;
} }
int type = header[2]; int type = header[2];
@ -142,23 +140,22 @@ namespace Resource
= reader->readImage(*stream, disableFlip ? mOptionsNoFlip : mOptions); = reader->readImage(*stream, disableFlip ? mOptionsNoFlip : mOptions);
if (!result.success()) if (!result.success())
{ {
Log(Debug::Error) << "Error loading " << filename << ": " << result.message() << " code " Log(Debug::Error) << "Error loading " << path << ": " << result.message() << " code "
<< result.status(); << result.status();
mCache->addEntryToObjectCache(normalized, mWarningImage); mCache->addEntryToObjectCache(path.value(), mWarningImage);
return mWarningImage; return mWarningImage;
} }
osg::ref_ptr<osg::Image> image = result.getImage(); osg::ref_ptr<osg::Image> image = result.getImage();
image->setFileName(normalized); image->setFileName(std::string(path.value()));
if (!checkSupported(image)) if (!checkSupported(image))
{ {
static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr); static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != nullptr);
if (!uncompress) if (!uncompress)
{ {
Log(Debug::Error) << "Error loading " << filename Log(Debug::Error) << "Error loading " << path << ": no S3TC texture compression support installed";
<< ": no S3TC texture compression support installed"; mCache->addEntryToObjectCache(path.value(), mWarningImage);
mCache->addEntryToObjectCache(normalized, mWarningImage);
return mWarningImage; return mWarningImage;
} }
else else
@ -189,7 +186,7 @@ namespace Resource
image = newImage; image = newImage;
} }
mCache->addEntryToObjectCache(normalized, image); mCache->addEntryToObjectCache(path.value(), image);
return image; return image;
} }
} }

@ -1,13 +1,12 @@
#ifndef OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H #ifndef OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H
#define OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H #define OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H
#include <map>
#include <string>
#include <osg/Image> #include <osg/Image>
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <components/vfs/pathutil.hpp>
#include "resourcemanager.hpp" #include "resourcemanager.hpp"
namespace osgDB namespace osgDB
@ -28,7 +27,7 @@ namespace Resource
/// Create or retrieve an Image /// Create or retrieve an Image
/// Returns the dummy image if the given image is not found. /// Returns the dummy image if the given image is not found.
osg::ref_ptr<osg::Image> getImage(std::string_view filename, bool disableFlip = false); osg::ref_ptr<osg::Image> getImage(VFS::Path::NormalizedView path, bool disableFlip = false);
osg::Image* getWarningImage(); osg::Image* getWarningImage();

@ -627,7 +627,8 @@ namespace Resource
filePath = std::filesystem::relative(filename, osgDB::getCurrentWorkingDirectory()); filePath = std::filesystem::relative(filename, osgDB::getCurrentWorkingDirectory());
try try
{ {
return osgDB::ReaderWriter::ReadResult(mImageManager->getImage(Files::pathToUnicodeString(filePath)), return osgDB::ReaderWriter::ReadResult(
mImageManager->getImage(VFS::Path::toNormalized(Files::pathToUnicodeString(filePath))),
osgDB::ReaderWriter::ReadResult::FILE_LOADED); osgDB::ReaderWriter::ReadResult::FILE_LOADED);
} }
catch (std::exception& e) catch (std::exception& e)

@ -221,7 +221,7 @@ namespace SceneUtil
std::vector<osg::ref_ptr<osg::Texture2D>> textures; std::vector<osg::ref_ptr<osg::Texture2D>> textures;
for (const std::string& name : glowTextureNames) for (const std::string& name : glowTextureNames)
{ {
osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(name); osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(VFS::Path::toNormalized(name));
osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image)); osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image));
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT); tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT); tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT);

@ -404,17 +404,19 @@ namespace Shader
bool normalHeight = false; bool normalHeight = false;
std::string normalHeightMap = normalMapFileName; std::string normalHeightMap = normalMapFileName;
Misc::StringUtils::replaceLast(normalHeightMap, ".", mNormalHeightMapPattern + "."); Misc::StringUtils::replaceLast(normalHeightMap, ".", mNormalHeightMapPattern + ".");
if (mImageManager.getVFS()->exists(normalHeightMap)) const VFS::Path::Normalized normalHeightMapPath(normalHeightMap);
if (mImageManager.getVFS()->exists(normalHeightMapPath))
{ {
image = mImageManager.getImage(normalHeightMap); image = mImageManager.getImage(normalHeightMapPath);
normalHeight = true; normalHeight = true;
} }
else else
{ {
Misc::StringUtils::replaceLast(normalMapFileName, ".", mNormalMapPattern + "."); Misc::StringUtils::replaceLast(normalMapFileName, ".", mNormalMapPattern + ".");
if (mImageManager.getVFS()->exists(normalMapFileName)) const VFS::Path::Normalized normalMapPath(normalMapFileName);
if (mImageManager.getVFS()->exists(normalMapPath))
{ {
image = mImageManager.getImage(normalMapFileName); image = mImageManager.getImage(normalMapPath);
} }
} }
// Avoid using the auto-detected normal map if it's already being used as a bump map. // Avoid using the auto-detected normal map if it's already being used as a bump map.
@ -464,9 +466,10 @@ namespace Shader
{ {
std::string specularMapFileName = diffuseMap->getImage(0)->getFileName(); std::string specularMapFileName = diffuseMap->getImage(0)->getFileName();
Misc::StringUtils::replaceLast(specularMapFileName, ".", mSpecularMapPattern + "."); Misc::StringUtils::replaceLast(specularMapFileName, ".", mSpecularMapPattern + ".");
if (mImageManager.getVFS()->exists(specularMapFileName)) const VFS::Path::Normalized specularMapPath(specularMapFileName);
if (mImageManager.getVFS()->exists(specularMapPath))
{ {
osg::ref_ptr<osg::Image> image(mImageManager.getImage(specularMapFileName)); osg::ref_ptr<osg::Image> image(mImageManager.getImage(specularMapPath));
osg::ref_ptr<osg::Texture2D> specularMapTex(new osg::Texture2D(image)); osg::ref_ptr<osg::Texture2D> specularMapTex(new osg::Texture2D(image));
specularMapTex->setTextureSize(image->s(), image->t()); specularMapTex->setTextureSize(image->s(), image->t());
specularMapTex->setWrap(osg::Texture::WRAP_S, diffuseMap->getWrap(osg::Texture::WRAP_S)); specularMapTex->setWrap(osg::Texture::WRAP_S, diffuseMap->getWrap(osg::Texture::WRAP_S));

@ -44,7 +44,8 @@ namespace Terrain
return static_cast<osg::Texture2D*>(obj.get()); return static_cast<osg::Texture2D*>(obj.get());
else else
{ {
osg::ref_ptr<osg::Texture2D> texture(new osg::Texture2D(mSceneManager->getImageManager()->getImage(name))); osg::ref_ptr<osg::Texture2D> texture(
new osg::Texture2D(mSceneManager->getImageManager()->getImage(VFS::Path::toNormalized(name))));
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
mSceneManager->applyFilterSettings(texture); mSceneManager->applyFilterSettings(texture);

Loading…
Cancel
Save