فهرست منبع

Merge pull request #9867 from Popov72/fix-triplanar

Fix triplanar material when mesh position is not at the origin
David Catuhe 4 سال پیش
والد
کامیت
df2fbe11fc
2فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 1 0
      dist/preview release/what's new.md
  2. 3 3
      materialsLibrary/src/triPlanar/triplanar.vertex.fx

+ 1 - 0
dist/preview release/what's new.md

@@ -122,6 +122,7 @@
 - Fix issue when canvas loses focus while holding a pointer button ([PolygonalSun](https://github.com/PolygonalSun))
 - Fix issue where camera controls stay detached if PointerDragBehavior is disabled prematurely ([PolygonalSun](https://github.com/PolygonalSun))
 - Fix uncatchable exception that could be thrown when initializing the environment textures ([CoPrez](https://github.com/CoPrez))
+- Fix the triplanar material when the position of the mesh it is applied to is not (0,0,0) ([Popov72](https://github.com/Popov72))
 
 ## Breaking changes
 

+ 3 - 3
materialsLibrary/src/triPlanar/triplanar.vertex.fx

@@ -91,9 +91,9 @@ void main(void)
 	vec3 worldBinormal = normalize(xbin * normalizedNormal.x + ybin * normalizedNormal.y + zbin * normalizedNormal.z);
    	vec3 worldTangent = normalize(xtan * normalizedNormal.x + ytan * normalizedNormal.y + ztan * normalizedNormal.z);
 	   
-	worldTangent = (world * vec4(worldTangent, 1.0)).xyz;
-    worldBinormal = (world * vec4(worldBinormal, 1.0)).xyz;
-	vec3 worldNormal = (world * vec4(normalize(normal), 1.0)).xyz;
+	worldTangent = (world * vec4(worldTangent, 0.0)).xyz;
+    worldBinormal = (world * vec4(worldBinormal, 0.0)).xyz;
+	vec3 worldNormal = (world * vec4(normalize(normal), 0.0)).xyz;
 
 	tangentSpace[0] = worldTangent;
     tangentSpace[1] = worldBinormal;