Skip to content

Commit 9cedb85

Browse files
authored
Revert "Fix normals when mesh has both two-sided material and negative scale (playcanvas#2375)" (playcanvas#2406)
This reverts commit 4d5f59d. # Conflicts: # src/graphics/program-lib/programs/standard.js
1 parent 55e477a commit 9cedb85

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/graphics/program-lib/programs/standard.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,21 +1332,16 @@ var standard = {
13321332

13331333
code = this._fsAddStartCode(code, device, chunks, options);
13341334

1335-
if (needsNormal) {
1336-
code += " getViewDir();\n";
1337-
}
1338-
13391335
if (needsNormal) {
13401336
if (options.twoSidedLighting) {
1341-
code += " float normalDirSign = sign(dot(vNormalW, dViewDirW));\n";
1342-
code += " dVertexNormalW = normalDirSign * vNormalW;\n";
1337+
code += " dVertexNormalW = gl_FrontFacing ? vNormalW : -vNormalW;\n";
13431338
} else {
13441339
code += " dVertexNormalW = vNormalW;\n";
13451340
}
13461341
if ((options.heightMap || options.normalMap) && options.hasTangents) {
13471342
if (options.twoSidedLighting) {
1348-
code += " dTangentW = normalDirSign * vTangentW;\n";
1349-
code += " dBinormalW = normalDirSign * vBinormalW;\n";
1343+
code += " dTangentW = gl_FrontFacing ? vTangentW : -vTangentW;\n";
1344+
code += " dBinormalW = gl_FrontFacing ? vBinormalW : -vBinormalW;\n";
13501345
} else {
13511346
code += " dTangentW = vTangentW;\n";
13521347
code += " dBinormalW = vBinormalW;\n";
@@ -1371,6 +1366,7 @@ var standard = {
13711366
var getGlossinessCalled = false;
13721367

13731368
if (needsNormal) {
1369+
code += " getViewDir();\n";
13741370
if (options.heightMap || options.normalMap || options.clearCoatNormalMap || options.enableGGXSpecular) {
13751371
code += " getTBN();\n";
13761372
}

0 commit comments

Comments
 (0)