From e2e7b58b3a8fb4fabe148e3696ba48e25ad4856e Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sun, 20 Apr 2025 23:55:38 +0100 Subject: [PATCH] Handle normalHeightMap as special case --- components/shader/shadervisitor.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 092ff47dca..0e6b5e79c6 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -287,11 +287,17 @@ namespace Shader addedState->setName("addedState"); } - const char* defaultTextures[] = { "diffuseMap", "normalMap", "normalHeightMap", "emissiveMap", "darkMap", - "detailMap", "envMap", "specularMap", "decalMap", "bumpMap", "glossMap" }; + // This list is used both for detecting known texture types (including added normal maps etc.) and setting the + // shader defines. Normal maps and normal height maps both get sent to the shader as a normal map, so the latter + // must be detected separately. + const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", + "specularMap", "decalMap", "bumpMap", "glossMap" }; bool isTextureNameRecognized(std::string_view name) { - return std::find(std::begin(defaultTextures), std::end(defaultTextures), name) != std::end(defaultTextures); + if (std::find(std::begin(defaultTextures), std::end(defaultTextures), name) != std::end(defaultTextures)) + return true; + else + return name == "normalHeightMap"; } void ShaderVisitor::applyStateSet(osg::ref_ptr stateset, osg::Node& node)