EOL" aDeltaUVMatrix = mat2 (aDeltaUVMatrix[1][1], -aDeltaUVMatrix[0][1], -aDeltaUVMatrix[1][0], aDeltaUVMatrix[0][0]);"
EOL" mat2x3 aDeltaVectorMatrix = mat2x3 (dFdx (PositionWorld.xyz), dFdy (PositionWorld.xyz));"
EOL" aDeltaVectorMatrix = aDeltaVectorMatrix * aDeltaUVMatrix;"
- EOL" aDeltaVectorMatrix[0] = aDeltaVectorMatrix[0] - dot(Normal, aDeltaVectorMatrix[0]) * Normal;"
- EOL" aDeltaVectorMatrix[1] = aDeltaVectorMatrix[1] - dot(Normal, aDeltaVectorMatrix[1]) * Normal;"
- EOL" Normal = mat3 (-normalize(aDeltaVectorMatrix[0]), -normalize(aDeltaVectorMatrix[1]), Normal) * aMapNormalValue.xyz;"
+ EOL" aDeltaVectorMatrix[0] = normalize(aDeltaVectorMatrix[0] - dot(Normal, aDeltaVectorMatrix[0]) * Normal);"
+ EOL" aDeltaVectorMatrix[1] = normalize(aDeltaVectorMatrix[1] - dot(Normal, aDeltaVectorMatrix[1]) * Normal);"
+ EOL" float aDirection = gl_FrontFacing ? 1.0 : -1.0;"
+ EOL" Normal = mat3 (aDirection * aDeltaVectorMatrix[0], aDirection * aDeltaVectorMatrix[1], Normal) * aMapNormalValue.xyz;"
EOL" }"
EOL"#endif";
}
--- /dev/null
+puts "========"
+puts "0031302: Visualization, TKOpenGl - wrong tangent space calculation for normal maps"
+puts "Test for tangent space orientation."
+puts "========"
+
+pload XDE OCAF MODELING VISUALIZATION
+
+vclear
+vclose ALL
+
+vinit v -w 1024 -h 1024
+vcamera -persp
+vbackground -cubemap [locate_data_file Circus_CubeMap_V.png]
+vrenderparams -shadingModel PBR
+
+vlight -clear
+vlight -add ambient
+
+catch { Close D }
+ReadGltf D [locate_data_file bug31302_NormalTangentTest.gltf]
+XDisplay -dispmode 1 D
+
+vfront
+vfit
+vdump $imagedir/${casename}_front.png
+
+vback
+vdump $imagedir/${casename}_back.png