mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 18:32:36 +00:00
More BGSM cleanup
This commit is contained in:
parent
6be2bb70c3
commit
77c3cd4467
@ -38,9 +38,7 @@ namespace Bgsm
|
||||
}
|
||||
stream.read(mGrayscaleToPaletteColor);
|
||||
if (mVersion >= 6)
|
||||
{
|
||||
stream.read(mMaskWrites);
|
||||
}
|
||||
}
|
||||
|
||||
void BGSMFile::read(BGSMStream& stream)
|
||||
@ -59,9 +57,7 @@ namespace Bgsm
|
||||
stream.read(mLightingMap);
|
||||
stream.read(mFlowMap);
|
||||
if (mVersion >= 17)
|
||||
{
|
||||
stream.read(mDistanceFieldAlphaMap);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -98,9 +94,7 @@ namespace Bgsm
|
||||
stream.read(mWetnessControlSpecPowerScale);
|
||||
stream.read(mWetnessControlSpecMinvar);
|
||||
if (mVersion < 10)
|
||||
{
|
||||
stream.read(mWetnessControlEnvMapScale);
|
||||
}
|
||||
stream.read(mWetnessControlFresnelPower);
|
||||
stream.read(mWetnessControlMetalness);
|
||||
if (mVersion >= 3)
|
||||
@ -116,9 +110,7 @@ namespace Bgsm
|
||||
stream.read(mAnisoLighting);
|
||||
stream.read(mEmitEnabled);
|
||||
if (mEmitEnabled)
|
||||
{
|
||||
stream.read(mEmittanceColor);
|
||||
}
|
||||
stream.read(mEmittanceMult);
|
||||
stream.read(mModelSpaceNormals);
|
||||
stream.read(mExternalEmittance);
|
||||
@ -181,14 +173,14 @@ namespace Bgsm
|
||||
stream.read(mEnvMap);
|
||||
stream.read(mNormalMap);
|
||||
stream.read(mEnvMapMask);
|
||||
if (mVersion >= 11)
|
||||
{
|
||||
stream.read(mSpecularMap);
|
||||
stream.read(mLightingMap);
|
||||
stream.read(mGlowMap);
|
||||
}
|
||||
if (mVersion >= 10)
|
||||
{
|
||||
if (mVersion >= 11)
|
||||
{
|
||||
stream.read(mSpecularMap);
|
||||
stream.read(mLightingMap);
|
||||
stream.read(mGlowMap);
|
||||
}
|
||||
stream.read(mEnvMapEnabled);
|
||||
stream.read(mEnvMapMaskScale);
|
||||
}
|
||||
@ -205,20 +197,12 @@ namespace Bgsm
|
||||
stream.read(mEnvmapMinLOD);
|
||||
stream.read(mSoftDepth);
|
||||
if (mVersion >= 11)
|
||||
{
|
||||
stream.read(mEmittanceColor);
|
||||
if (mVersion >= 15)
|
||||
{
|
||||
stream.read(mAdaptiveEmissiveExposureParams);
|
||||
if (mVersion >= 16)
|
||||
{
|
||||
stream.read(mGlowMapEnabled);
|
||||
if (mVersion >= 20)
|
||||
{
|
||||
stream.read(mEffectPbrSpecular);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mVersion >= 15)
|
||||
stream.read(mAdaptiveEmissiveExposureParams);
|
||||
if (mVersion >= 16)
|
||||
stream.read(mGlowMapEnabled);
|
||||
if (mVersion >= 20)
|
||||
stream.read(mEffectPbrSpecular);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace Bgsm
|
||||
|
||||
MaterialFile() = default;
|
||||
virtual void read(BGSMStream& stream);
|
||||
virtual ~MaterialFile() {}
|
||||
virtual ~MaterialFile() = default;
|
||||
};
|
||||
|
||||
struct BGSMFile : MaterialFile
|
||||
|
@ -31,5 +31,4 @@ namespace Bgsm
|
||||
|
||||
mFile->read(stream);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Bgsm
|
||||
{
|
||||
|
||||
template <>
|
||||
void BGSMStream::read<osg::Vec2f>(osg::Vec2f& vec)
|
||||
{
|
||||
@ -37,5 +36,4 @@ namespace Bgsm
|
||||
if (end != std::string::npos)
|
||||
str.erase(end);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2151,18 +2151,19 @@ namespace NifOsg
|
||||
handleTextureControllers(texprop, composite, stateset, animflags);
|
||||
}
|
||||
|
||||
Bgsm::MaterialFilePtr getShaderMaterial(std::string_view path) const
|
||||
static Bgsm::MaterialFilePtr getShaderMaterial(
|
||||
std::string_view path, Resource::BgsmFileManager* materialManager)
|
||||
{
|
||||
if (!mMaterialManager)
|
||||
if (!materialManager)
|
||||
return nullptr;
|
||||
|
||||
if (!Misc::StringUtils::ciEndsWith(path, ".bgem") && !Misc::StringUtils::ciEndsWith(path, ".bgsm"))
|
||||
return nullptr;
|
||||
|
||||
std::string normalizedPath = Misc::ResourceHelpers::correctMaterialPath(path, mMaterialManager->getVFS());
|
||||
std::string normalizedPath = Misc::ResourceHelpers::correctMaterialPath(path, materialManager->getVFS());
|
||||
try
|
||||
{
|
||||
return mMaterialManager->get(VFS::Path::Normalized(normalizedPath));
|
||||
return materialManager->get(VFS::Path::Normalized(normalizedPath));
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
@ -2528,7 +2529,7 @@ namespace NifOsg
|
||||
node->setUserValue("shaderRequired", shaderRequired);
|
||||
osg::StateSet* stateset = node->getOrCreateStateSet();
|
||||
clearBoundTextures(stateset, boundTextures);
|
||||
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName))
|
||||
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager))
|
||||
{
|
||||
handleShaderMaterialNodeProperties(material, stateset, boundTextures);
|
||||
break;
|
||||
@ -2557,7 +2558,7 @@ namespace NifOsg
|
||||
node->setUserValue("shaderRequired", shaderRequired);
|
||||
osg::StateSet* stateset = node->getOrCreateStateSet();
|
||||
clearBoundTextures(stateset, boundTextures);
|
||||
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName))
|
||||
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager))
|
||||
{
|
||||
handleShaderMaterialNodeProperties(material, stateset, boundTextures);
|
||||
break;
|
||||
@ -2776,15 +2777,14 @@ namespace NifOsg
|
||||
case Nif::RC_BSLightingShaderProperty:
|
||||
{
|
||||
auto shaderprop = static_cast<const Nif::BSLightingShaderProperty*>(property);
|
||||
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName))
|
||||
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager))
|
||||
{
|
||||
handleShaderMaterialDrawableProperties(shaderMat, mat, *node, hasSortAlpha);
|
||||
if (shaderMat->mShaderType == Bgsm::ShaderType::Lighting)
|
||||
{
|
||||
auto bgsm = static_cast<const Bgsm::BGSMFile*>(shaderMat.get());
|
||||
specEnabled
|
||||
= false; // bgsm->mSpecularEnabled; disabled until it can be implemented properly
|
||||
specStrength = bgsm->mSpecularMult;
|
||||
specEnabled = false; // bgsm->mSpecularEnabled; TODO: PBR specular lighting
|
||||
specStrength = 1.f; // bgsm->mSpecularMult;
|
||||
emissiveMult = bgsm->mEmittanceMult;
|
||||
}
|
||||
break;
|
||||
@ -2803,7 +2803,7 @@ namespace NifOsg
|
||||
case Nif::RC_BSEffectShaderProperty:
|
||||
{
|
||||
auto shaderprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
|
||||
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName))
|
||||
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager))
|
||||
{
|
||||
handleShaderMaterialDrawableProperties(shaderMat, mat, *node, hasSortAlpha);
|
||||
break;
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "bgsmfilemanager.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <osg/Object>
|
||||
|
||||
#include <components/bgsm/reader.hpp>
|
||||
@ -36,8 +34,6 @@ namespace Resource
|
||||
{
|
||||
}
|
||||
|
||||
BgsmFileManager::~BgsmFileManager() = default;
|
||||
|
||||
Bgsm::MaterialFilePtr BgsmFileManager::get(VFS::Path::NormalizedView name)
|
||||
{
|
||||
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name);
|
||||
|
@ -14,7 +14,7 @@ namespace Resource
|
||||
{
|
||||
public:
|
||||
BgsmFileManager(const VFS::Manager* vfs, double expiryDelay);
|
||||
~BgsmFileManager();
|
||||
~BgsmFileManager() = default;
|
||||
|
||||
/// Retrieve a material file from the cache or load it from the VFS if not cached yet.
|
||||
Bgsm::MaterialFilePtr get(VFS::Path::NormalizedView name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user