File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
src/graphics/program-lib/programs Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -1332,21 +1332,16 @@ var standard = {
1332
1332
1333
1333
code = this . _fsAddStartCode ( code , device , chunks , options ) ;
1334
1334
1335
- if ( needsNormal ) {
1336
- code += " getViewDir();\n" ;
1337
- }
1338
-
1339
1335
if ( needsNormal ) {
1340
1336
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" ;
1343
1338
} else {
1344
1339
code += " dVertexNormalW = vNormalW;\n" ;
1345
1340
}
1346
1341
if ( ( options . heightMap || options . normalMap ) && options . hasTangents ) {
1347
1342
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" ;
1350
1345
} else {
1351
1346
code += " dTangentW = vTangentW;\n" ;
1352
1347
code += " dBinormalW = vBinormalW;\n" ;
@@ -1371,6 +1366,7 @@ var standard = {
1371
1366
var getGlossinessCalled = false ;
1372
1367
1373
1368
if ( needsNormal ) {
1369
+ code += " getViewDir();\n" ;
1374
1370
if ( options . heightMap || options . normalMap || options . clearCoatNormalMap || options . enableGGXSpecular ) {
1375
1371
code += " getTBN();\n" ;
1376
1372
}
You can’t perform that action at this time.
0 commit comments