From 6330d80b9e8f22e29e35820737ef4583e0fa28b1 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 24 Oct 2024 13:36:49 +0100 Subject: [PATCH 1/2] Don't expect TangentSpaceGenerator to work without texcoords --- components/shader/shadervisitor.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 63ee6cb41f4..d97276576fa 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -889,12 +889,29 @@ namespace Shader if (mAllowedToModifyStateSets && (useShader || generateTangents)) { // make sure that all UV sets are there - for (std::map::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); - ++it) + // it's not safe to assume there's one for slot zero, so try and use one from another slot if possible + // if there are none at all, bail. + // the TangentSpaceGenerator would bail, but getTangentArray would give an empty array, which is enough to + // bypass null checks, but feeds the driver a bad pointer + if (sourceGeometry.getTexCoordArray(0) == nullptr) + { + for (const auto& array : sourceGeometry.getTexCoordArrayList()) + { + if (array) + { + sourceGeometry.setTexCoordArray(0, array); + break; + } + } + if (sourceGeometry.getTexCoordArray(0) == nullptr) + return changed; + } + + for (const auto& [unit, name] : reqs.mTextures) { - if (sourceGeometry.getTexCoordArray(it->first) == nullptr) + if (sourceGeometry.getTexCoordArray(unit) == nullptr) { - sourceGeometry.setTexCoordArray(it->first, sourceGeometry.getTexCoordArray(0)); + sourceGeometry.setTexCoordArray(unit, sourceGeometry.getTexCoordArray(0)); changed = true; } } From a95b3672cf68598806a59c604c53256ba5fe5c18 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Fri, 25 Oct 2024 23:37:18 +0100 Subject: [PATCH 2/2] c h a n g e l o g --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4a1e1f4d6..dc3722f394d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ Bug #7307: Alchemy "Magic Effect" search string does not match on tool tip for effects related to attributes Bug #7309: Sunlight scattering is visible in inappropriate situations Bug #7322: Shadows don't cover groundcover depending on the view angle and perspective with compute scene bounds = primitives + Bug #7353: Normal Map Crashes with Starwind Assets in TES3MP and OpenMW Bug #7354: Disabling post processing in-game causes a crash Bug #7364: Post processing is not reflected in savegame previews Bug #7380: NiZBufferProperty issue