1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-29 03:36:40 +00:00

Merge branch 'normally-we-have-a-uv-set' into 'master'

Don't expect TangentSpaceGenerator to work without texcoords

Closes #7353

See merge request OpenMW/openmw!4423
This commit is contained in:
Alexei Kotov 2024-10-27 03:58:43 +00:00
commit 0d702689d0
2 changed files with 22 additions and 4 deletions

View file

@ -96,6 +96,7 @@
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 #7309: Sunlight scattering is visible in inappropriate situations 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 #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 #7354: Disabling post processing in-game causes a crash
Bug #7364: Post processing is not reflected in savegame previews Bug #7364: Post processing is not reflected in savegame previews
Bug #7380: NiZBufferProperty issue Bug #7380: NiZBufferProperty issue

View file

@ -889,12 +889,29 @@ namespace Shader
if (mAllowedToModifyStateSets && (useShader || generateTangents)) if (mAllowedToModifyStateSets && (useShader || generateTangents))
{ {
// make sure that all UV sets are there // make sure that all UV sets are there
for (std::map<int, std::string>::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); // it's not safe to assume there's one for slot zero, so try and use one from another slot if possible
++it) // 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)
{ {
if (sourceGeometry.getTexCoordArray(it->first) == nullptr) for (const auto& array : sourceGeometry.getTexCoordArrayList())
{ {
sourceGeometry.setTexCoordArray(it->first, sourceGeometry.getTexCoordArray(0)); if (array)
{
sourceGeometry.setTexCoordArray(0, array);
break;
}
}
if (sourceGeometry.getTexCoordArray(0) == nullptr)
return changed;
}
for (const auto& [unit, name] : reqs.mTextures)
{
if (sourceGeometry.getTexCoordArray(unit) == nullptr)
{
sourceGeometry.setTexCoordArray(unit, sourceGeometry.getTexCoordArray(0));
changed = true; changed = true;
} }
} }