mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 06:44:29 +00:00
Further adjust FO3+ shader properties based on nifly definitions
This commit is contained in:
parent
4db994cda9
commit
82eed09604
@ -124,22 +124,74 @@ namespace Nif
|
|||||||
|
|
||||||
void BSShaderProperty::read(NIFStream* nif)
|
void BSShaderProperty::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
|
if (nif->getBethVersion() < NIFFile::BethVersion::BETHVER_F76 && recType == RC_BSLightingShaderProperty)
|
||||||
|
nif->read(mType);
|
||||||
|
|
||||||
NiShadeProperty::read(nif);
|
NiShadeProperty::read(nif);
|
||||||
|
|
||||||
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO3)
|
if (nif->getUserVersion() <= 11)
|
||||||
{
|
{
|
||||||
nif->read(mType);
|
nif->read(mType);
|
||||||
nif->read(mShaderFlags1);
|
nif->read(mShaderFlags1);
|
||||||
nif->read(mShaderFlags2);
|
nif->read(mShaderFlags2);
|
||||||
nif->read(mEnvMapScale);
|
nif->read(mEnvMapScale);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mName.empty() && nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (nif->getBethVersion() <= 131)
|
||||||
|
{
|
||||||
|
nif->read(mShaderFlags1);
|
||||||
|
nif->read(mShaderFlags2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32_t numShaderFlags1 = 0, numShaderFlags2 = 0;
|
||||||
|
nif->read(numShaderFlags1);
|
||||||
|
if (nif->getBethVersion() >= 152)
|
||||||
|
nif->read(numShaderFlags2);
|
||||||
|
nif->readVector(mShaderFlags1Hashes, numShaderFlags1);
|
||||||
|
nif->readVector(mShaderFlags2Hashes, numShaderFlags2);
|
||||||
|
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76 && recType == RC_BSLightingShaderProperty)
|
||||||
|
{
|
||||||
|
nif->read(mType);
|
||||||
|
|
||||||
|
// Remap FO76+ shader types to FO4 system so that we can actually use them
|
||||||
|
// TODO: NifTools spec doesn't do anything about the misplaced EyeEnvmap. Bug or feature?
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_FaceTint);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_SkinTint);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_HairTint);
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_EyeEnvmap);
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
|
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_Terrain);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nif->read(mUVOffset);
|
||||||
|
nif->read(mUVScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSShaderLightingProperty::read(NIFStream* nif)
|
void BSShaderLightingProperty::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
BSShaderProperty::read(nif);
|
BSShaderProperty::read(nif);
|
||||||
|
|
||||||
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO3)
|
if (nif->getUserVersion() <= 11)
|
||||||
nif->read(mClamp);
|
nif->read(mClamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,10 +200,15 @@ namespace Nif
|
|||||||
BSShaderLightingProperty::read(nif);
|
BSShaderLightingProperty::read(nif);
|
||||||
|
|
||||||
mTextureSet.read(nif);
|
mTextureSet.read(nif);
|
||||||
if (nif->getBethVersion() >= 15)
|
if (nif->getUserVersion() == 11)
|
||||||
mRefraction.read(nif);
|
{
|
||||||
if (nif->getBethVersion() >= 25)
|
if (nif->getBethVersion() >= 15)
|
||||||
mParallax.read(nif);
|
mRefraction.read(nif);
|
||||||
|
if (nif->getBethVersion() >= 25)
|
||||||
|
mParallax.read(nif);
|
||||||
|
}
|
||||||
|
else if (nif->getUserVersion() >= 12)
|
||||||
|
nif->read(mEmissiveColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSShaderPPLightingProperty::post(Reader& nif)
|
void BSShaderPPLightingProperty::post(Reader& nif)
|
||||||
@ -212,31 +269,11 @@ namespace Nif
|
|||||||
|
|
||||||
void BSLightingShaderProperty::read(NIFStream* nif)
|
void BSLightingShaderProperty::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
if (nif->getBethVersion() <= 139)
|
|
||||||
nif->read(mType);
|
|
||||||
|
|
||||||
BSShaderProperty::read(nif);
|
BSShaderProperty::read(nif);
|
||||||
|
|
||||||
if (nif->getBethVersion() <= 130)
|
if (!mName.empty() && nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
|
||||||
{
|
return;
|
||||||
nif->read(mShaderFlags1);
|
|
||||||
nif->read(mShaderFlags2);
|
|
||||||
}
|
|
||||||
else if (nif->getBethVersion() >= 132)
|
|
||||||
{
|
|
||||||
uint32_t numShaderFlags1 = 0, numShaderFlags2 = 0;
|
|
||||||
nif->read(numShaderFlags1);
|
|
||||||
if (nif->getBethVersion() >= 152)
|
|
||||||
nif->read(numShaderFlags2);
|
|
||||||
nif->readVector(mShaderFlags1Hashes, numShaderFlags1);
|
|
||||||
nif->readVector(mShaderFlags2Hashes, numShaderFlags2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
|
|
||||||
nif->read(mType);
|
|
||||||
|
|
||||||
nif->read(mUVOffset);
|
|
||||||
nif->read(mUVScale);
|
|
||||||
mTextureSet.read(nif);
|
mTextureSet.read(nif);
|
||||||
nif->read(mEmissive);
|
nif->read(mEmissive);
|
||||||
nif->read(mEmissiveMult);
|
nif->read(mEmissiveMult);
|
||||||
@ -299,32 +336,6 @@ namespace Nif
|
|||||||
nif->skip(2); // Unknown
|
nif->skip(2); // Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
|
|
||||||
{
|
|
||||||
// Remap FO76+ shader types to FO4 system so that we can actually use them
|
|
||||||
// TODO: NifTools spec doesn't do anything about the misplaced EyeEnvmap. Bug or feature?
|
|
||||||
switch (static_cast<BSLightingShaderType>(mType))
|
|
||||||
{
|
|
||||||
case BSLightingShaderType::ShaderType_Parallax:
|
|
||||||
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_FaceTint);
|
|
||||||
break;
|
|
||||||
case BSLightingShaderType::ShaderType_FaceTint:
|
|
||||||
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_SkinTint);
|
|
||||||
break;
|
|
||||||
case BSLightingShaderType::ShaderType_SkinTint:
|
|
||||||
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_HairTint);
|
|
||||||
break;
|
|
||||||
case BSLightingShaderType::ShaderType_TreeAnim:
|
|
||||||
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_EyeEnvmap);
|
|
||||||
break;
|
|
||||||
case BSLightingShaderType::ShaderType_Cloud:
|
|
||||||
mType = static_cast<uint32_t>(BSLightingShaderType::ShaderType_Terrain);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (static_cast<BSLightingShaderType>(mType))
|
switch (static_cast<BSLightingShaderType>(mType))
|
||||||
{
|
{
|
||||||
case BSLightingShaderType::ShaderType_EnvMap:
|
case BSLightingShaderType::ShaderType_EnvMap:
|
||||||
@ -337,10 +348,9 @@ namespace Nif
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BSLightingShaderType::ShaderType_SkinTint:
|
case BSLightingShaderType::ShaderType_SkinTint:
|
||||||
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO4)
|
nif->read(mSkinTintColor);
|
||||||
mSkinTintColor = { nif->get<osg::Vec3f>(), 1.f };
|
if (nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO4)
|
||||||
else
|
nif->read(mSkinTintAlpha);
|
||||||
nif->read(mSkinTintColor);
|
|
||||||
break;
|
break;
|
||||||
case BSLightingShaderType::ShaderType_HairTint:
|
case BSLightingShaderType::ShaderType_HairTint:
|
||||||
nif->read(mHairTintColor);
|
nif->read(mHairTintColor);
|
||||||
@ -375,23 +385,9 @@ namespace Nif
|
|||||||
{
|
{
|
||||||
BSShaderProperty::read(nif);
|
BSShaderProperty::read(nif);
|
||||||
|
|
||||||
if (nif->getBethVersion() <= 130)
|
if (!mName.empty() && nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
|
||||||
{
|
return;
|
||||||
nif->read(mShaderFlags1);
|
|
||||||
nif->read(mShaderFlags2);
|
|
||||||
}
|
|
||||||
else if (nif->getBethVersion() >= 132)
|
|
||||||
{
|
|
||||||
uint32_t numShaderFlags1 = 0, numShaderFlags2 = 0;
|
|
||||||
nif->read(numShaderFlags1);
|
|
||||||
if (nif->getBethVersion() >= 152)
|
|
||||||
nif->read(numShaderFlags2);
|
|
||||||
nif->readVector(mShaderFlags1Hashes, numShaderFlags1);
|
|
||||||
nif->readVector(mShaderFlags2Hashes, numShaderFlags2);
|
|
||||||
}
|
|
||||||
|
|
||||||
nif->read(mUVOffset);
|
|
||||||
nif->read(mUVScale);
|
|
||||||
mSourceTexture = nif->getSizedString();
|
mSourceTexture = nif->getSizedString();
|
||||||
|
|
||||||
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_STF)
|
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_STF)
|
||||||
|
@ -113,16 +113,16 @@ namespace Nif
|
|||||||
|
|
||||||
struct BSSPParallaxParams
|
struct BSSPParallaxParams
|
||||||
{
|
{
|
||||||
float mMaxPasses;
|
float mMaxPasses{ 4.f };
|
||||||
float mScale;
|
float mScale{ 1.f };
|
||||||
|
|
||||||
void read(NIFStream* nif);
|
void read(NIFStream* nif);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BSSPRefractionParams
|
struct BSSPRefractionParams
|
||||||
{
|
{
|
||||||
float mStrength;
|
float mStrength{ 0.f };
|
||||||
int32_t mPeriod;
|
int32_t mPeriod{ 0 };
|
||||||
|
|
||||||
void read(NIFStream* nif);
|
void read(NIFStream* nif);
|
||||||
};
|
};
|
||||||
@ -131,6 +131,8 @@ namespace Nif
|
|||||||
{
|
{
|
||||||
uint32_t mType{ 0u }, mShaderFlags1{ 0u }, mShaderFlags2{ 0u };
|
uint32_t mType{ 0u }, mShaderFlags1{ 0u }, mShaderFlags2{ 0u };
|
||||||
float mEnvMapScale{ 0.f };
|
float mEnvMapScale{ 0.f };
|
||||||
|
std::vector<uint32_t> mShaderFlags1Hashes, mShaderFlags2Hashes;
|
||||||
|
osg::Vec2f mUVOffset, mUVScale;
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
|
|
||||||
@ -142,7 +144,7 @@ namespace Nif
|
|||||||
|
|
||||||
struct BSShaderLightingProperty : BSShaderProperty
|
struct BSShaderLightingProperty : BSShaderProperty
|
||||||
{
|
{
|
||||||
unsigned int mClamp{ 0u };
|
uint32_t mClamp{ 3 };
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
|
|
||||||
@ -155,6 +157,7 @@ namespace Nif
|
|||||||
BSShaderTextureSetPtr mTextureSet;
|
BSShaderTextureSetPtr mTextureSet;
|
||||||
BSSPRefractionParams mRefraction;
|
BSSPRefractionParams mRefraction;
|
||||||
BSSPParallaxParams mParallax;
|
BSSPParallaxParams mParallax;
|
||||||
|
osg::Vec4f mEmissiveColor;
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
void post(Reader& nif) override;
|
void post(Reader& nif) override;
|
||||||
@ -249,8 +252,6 @@ namespace Nif
|
|||||||
|
|
||||||
struct BSLightingShaderProperty : BSShaderProperty
|
struct BSLightingShaderProperty : BSShaderProperty
|
||||||
{
|
{
|
||||||
std::vector<uint32_t> mShaderFlags1Hashes, mShaderFlags2Hashes;
|
|
||||||
osg::Vec2f mUVOffset, mUVScale;
|
|
||||||
BSShaderTextureSetPtr mTextureSet;
|
BSShaderTextureSetPtr mTextureSet;
|
||||||
osg::Vec3f mEmissive;
|
osg::Vec3f mEmissive;
|
||||||
float mEmissiveMult;
|
float mEmissiveMult;
|
||||||
@ -277,7 +278,8 @@ namespace Nif
|
|||||||
bool mUseSSR;
|
bool mUseSSR;
|
||||||
bool mWetnessUseSSR;
|
bool mWetnessUseSSR;
|
||||||
|
|
||||||
osg::Vec4f mSkinTintColor;
|
osg::Vec3f mSkinTintColor;
|
||||||
|
float mSkinTintAlpha{ 1.f };
|
||||||
osg::Vec3f mHairTintColor;
|
osg::Vec3f mHairTintColor;
|
||||||
|
|
||||||
BSSPParallaxParams mParallax;
|
BSSPParallaxParams mParallax;
|
||||||
@ -297,8 +299,6 @@ namespace Nif
|
|||||||
|
|
||||||
struct BSEffectShaderProperty : BSShaderProperty
|
struct BSEffectShaderProperty : BSShaderProperty
|
||||||
{
|
{
|
||||||
std::vector<uint32_t> mShaderFlags1Hashes, mShaderFlags2Hashes;
|
|
||||||
osg::Vec2f mUVOffset, mUVScale;
|
|
||||||
std::string mSourceTexture;
|
std::string mSourceTexture;
|
||||||
uint8_t mClamp;
|
uint8_t mClamp;
|
||||||
uint8_t mLightingInfluence;
|
uint8_t mLightingInfluence;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user