mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-31 14:41:31 +00:00
Merge branch 'deepdepths' into 'master'
Depth flag handling fixes (bug #7380) See merge request OpenMW/openmw!3568
This commit is contained in:
commit
32a9581394
3 changed files with 75 additions and 13 deletions
|
@ -70,6 +70,7 @@
|
||||||
Bug #7298: Water ripples from projectiles sometimes are not spawned
|
Bug #7298: Water ripples from projectiles sometimes are not spawned
|
||||||
Bug #7307: Alchemy "Magic Effect" search string does not match on tool tip for effects related to attributes
|
Bug #7307: Alchemy "Magic Effect" search string does not match on tool tip for effects related to attributes
|
||||||
Bug #7322: Shadows don't cover groundcover depending on the view angle and perspective with compute scene bounds = primitives
|
Bug #7322: Shadows don't cover groundcover depending on the view angle and perspective with compute scene bounds = primitives
|
||||||
|
Bug #7380: NiZBufferProperty issue
|
||||||
Bug #7413: Generated wilderness cells don't spawn fish
|
Bug #7413: Generated wilderness cells don't spawn fish
|
||||||
Bug #7415: Unbreakable lock discrepancies
|
Bug #7415: Unbreakable lock discrepancies
|
||||||
Bug #7428: AutoCalc flag is not used to calculate enchantment costs
|
Bug #7428: AutoCalc flag is not used to calculate enchantment costs
|
||||||
|
|
|
@ -108,7 +108,64 @@ osg::Group {
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string formatOsgNodeForShaderProperty(std::string_view shaderPrefix)
|
std::string formatOsgNodeForBSShaderProperty(std::string_view shaderPrefix)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << R"(
|
||||||
|
osg::Group {
|
||||||
|
UniqueID 1
|
||||||
|
DataVariance STATIC
|
||||||
|
UserDataContainer TRUE {
|
||||||
|
osg::DefaultUserDataContainer {
|
||||||
|
UniqueID 2
|
||||||
|
UDC_UserObjects 1 {
|
||||||
|
osg::StringValueObject {
|
||||||
|
UniqueID 3
|
||||||
|
Name "fileHash"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Children 1 {
|
||||||
|
osg::Group {
|
||||||
|
UniqueID 4
|
||||||
|
DataVariance STATIC
|
||||||
|
UserDataContainer TRUE {
|
||||||
|
osg::DefaultUserDataContainer {
|
||||||
|
UniqueID 5
|
||||||
|
UDC_UserObjects 3 {
|
||||||
|
osg::UIntValueObject {
|
||||||
|
UniqueID 6
|
||||||
|
Name "recIndex"
|
||||||
|
Value 4294967295
|
||||||
|
}
|
||||||
|
osg::StringValueObject {
|
||||||
|
UniqueID 7
|
||||||
|
Name "shaderPrefix"
|
||||||
|
Value ")"
|
||||||
|
<< shaderPrefix << R"("
|
||||||
|
}
|
||||||
|
osg::BoolValueObject {
|
||||||
|
UniqueID 8
|
||||||
|
Name "shaderRequired"
|
||||||
|
Value TRUE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StateSet TRUE {
|
||||||
|
osg::StateSet {
|
||||||
|
UniqueID 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string formatOsgNodeForBSLightingShaderProperty(std::string_view shaderPrefix)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << R"(
|
oss << R"(
|
||||||
|
@ -162,7 +219,6 @@ osg::Group {
|
||||||
AttributeList 1 {
|
AttributeList 1 {
|
||||||
osg::Depth {
|
osg::Depth {
|
||||||
UniqueID 10
|
UniqueID 10
|
||||||
WriteMask FALSE
|
|
||||||
}
|
}
|
||||||
Value OFF
|
Value OFF
|
||||||
}
|
}
|
||||||
|
@ -204,7 +260,7 @@ osg::Group {
|
||||||
Nif::NIFFile file("test.nif");
|
Nif::NIFFile file("test.nif");
|
||||||
file.mRoots.push_back(&node);
|
file.mRoots.push_back(&node);
|
||||||
auto result = Loader::load(file, &mImageManager);
|
auto result = Loader::load(file, &mImageManager);
|
||||||
EXPECT_EQ(serialize(*result), formatOsgNodeForShaderProperty(GetParam().mExpectedShaderPrefix));
|
EXPECT_EQ(serialize(*result), formatOsgNodeForBSShaderProperty(GetParam().mExpectedShaderPrefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(Params, NifOsgLoaderBSShaderPrefixTest, ValuesIn(NifOsgLoaderBSShaderPrefixTest::sParams));
|
INSTANTIATE_TEST_SUITE_P(Params, NifOsgLoaderBSShaderPrefixTest, ValuesIn(NifOsgLoaderBSShaderPrefixTest::sParams));
|
||||||
|
@ -228,11 +284,13 @@ osg::Group {
|
||||||
property.mTextureSet = nullptr;
|
property.mTextureSet = nullptr;
|
||||||
property.mController = nullptr;
|
property.mController = nullptr;
|
||||||
property.mType = GetParam().mShaderType;
|
property.mType = GetParam().mShaderType;
|
||||||
|
property.mShaderFlags1 |= Nif::BSShaderFlags1::BSSFlag1_DepthTest;
|
||||||
|
property.mShaderFlags2 |= Nif::BSShaderFlags2::BSSFlag2_DepthWrite;
|
||||||
node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property));
|
node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property));
|
||||||
Nif::NIFFile file("test.nif");
|
Nif::NIFFile file("test.nif");
|
||||||
file.mRoots.push_back(&node);
|
file.mRoots.push_back(&node);
|
||||||
auto result = Loader::load(file, &mImageManager);
|
auto result = Loader::load(file, &mImageManager);
|
||||||
EXPECT_EQ(serialize(*result), formatOsgNodeForShaderProperty(GetParam().mExpectedShaderPrefix));
|
EXPECT_EQ(serialize(*result), formatOsgNodeForBSLightingShaderProperty(GetParam().mExpectedShaderPrefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
|
|
@ -1964,11 +1964,17 @@ namespace NifOsg
|
||||||
return texEnv;
|
return texEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleDepthFlags(osg::StateSet* stateset, bool depthTest, bool depthWrite,
|
void handleDepthFlags(osg::StateSet* stateset, bool depthTest, bool depthWrite)
|
||||||
osg::Depth::Function depthFunction = osg::Depth::LESS)
|
|
||||||
{
|
{
|
||||||
stateset->setMode(GL_DEPTH_TEST, depthTest ? osg::StateAttribute::ON : osg::StateAttribute::OFF);
|
if (!depthWrite && !depthTest)
|
||||||
osg::ref_ptr<osg::Depth> depth = new osg::Depth(depthFunction, 0.0, 1.0, depthWrite);
|
{
|
||||||
|
stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
osg::ref_ptr<osg::Depth> depth = new osg::Depth;
|
||||||
|
depth->setWriteMask(depthWrite);
|
||||||
|
if (!depthTest)
|
||||||
|
depth->setFunction(osg::Depth::ALWAYS);
|
||||||
depth = shareAttribute(depth);
|
depth = shareAttribute(depth);
|
||||||
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
|
||||||
}
|
}
|
||||||
|
@ -2328,10 +2334,8 @@ namespace NifOsg
|
||||||
{
|
{
|
||||||
const Nif::NiZBufferProperty* zprop = static_cast<const Nif::NiZBufferProperty*>(property);
|
const Nif::NiZBufferProperty* zprop = static_cast<const Nif::NiZBufferProperty*>(property);
|
||||||
osg::StateSet* stateset = node->getOrCreateStateSet();
|
osg::StateSet* stateset = node->getOrCreateStateSet();
|
||||||
// Morrowind ignores depth test function, unless a NiStencilProperty is present, in which case it
|
// The test function from this property seems to be ignored.
|
||||||
// uses a fixed depth function of GL_ALWAYS.
|
handleDepthFlags(stateset, zprop->depthTest(), zprop->depthWrite());
|
||||||
osg::Depth::Function depthFunction = hasStencilProperty ? osg::Depth::ALWAYS : osg::Depth::LESS;
|
|
||||||
handleDepthFlags(stateset, zprop->depthTest(), zprop->depthWrite(), depthFunction);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// OSG groups the material properties that NIFs have separate, so we have to parse them all again when
|
// OSG groups the material properties that NIFs have separate, so we have to parse them all again when
|
||||||
|
@ -2370,7 +2374,6 @@ namespace NifOsg
|
||||||
textureSet, texprop->mClamp, node->getName(), stateset, imageManager, boundTextures);
|
textureSet, texprop->mClamp, node->getName(), stateset, imageManager, boundTextures);
|
||||||
}
|
}
|
||||||
handleTextureControllers(texprop, composite, imageManager, stateset, animflags);
|
handleTextureControllers(texprop, composite, imageManager, stateset, animflags);
|
||||||
handleDepthFlags(stateset, texprop->depthTest(), texprop->depthWrite());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Nif::RC_BSShaderNoLightingProperty:
|
case Nif::RC_BSShaderNoLightingProperty:
|
||||||
|
|
Loading…
Reference in a new issue