Browse Source

Merge pull request #107453 from LunaCapra/bent-normals-triplanar

Fix bent normal maps not working with triplanar UVs
Rémi Verschelde 2 months ago
parent
commit
6c52478491
1 changed files with 5 additions and 1 deletions
  1. 5 1
      scene/resources/material.cpp

+ 5 - 1
scene/resources/material.cpp

@@ -1745,8 +1745,12 @@ void fragment() {)";
 	if (features[FEATURE_BENT_NORMAL_MAPPING]) {
 	if (features[FEATURE_BENT_NORMAL_MAPPING]) {
 		code += R"(
 		code += R"(
 	// Bent Normal Map: Enabled
 	// Bent Normal Map: Enabled
-	BENT_NORMAL_MAP = texture(texture_bent_normal, base_uv).rgb;
 )";
 )";
+		if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+			code += "	BENT_NORMAL_MAP = triplanar_texture(texture_bent_normal, uv1_power_normal, uv1_triplanar_pos).rgb;\n";
+		} else {
+			code += "	BENT_NORMAL_MAP = texture(texture_bent_normal, base_uv).rgb;\n";
+		}
 	}
 	}
 
 
 	if (features[FEATURE_EMISSION]) {
 	if (features[FEATURE_EMISSION]) {