Skip to content

Commit 4e2ce81

Browse files
committed
Normal: Don't flip normals when using flat shading.
1 parent b7305bc commit 4e2ce81

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/nodes/accessors/Normal.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ export const transformedNormalView = /*@__PURE__*/ ( Fn( ( builder ) => {
8383

8484
// Use getUV context to avoid side effects from nodes overwriting getUV in the context (e.g. EnvironmentNode)
8585

86-
return builder.context.setupNormal().context( { getUV: null } );
86+
let node = builder.context.setupNormal().context( { getUV: null } );
8787

88-
}, 'vec3' ).once() )().mul( faceDirection ).toVar( 'transformedNormalView' );
88+
if ( builder.material.flatShading === false ) node = node.mul( faceDirection );
89+
90+
return node;
91+
92+
}, 'vec3' ).once() )().toVar( 'transformedNormalView' );
8993

9094
/**
9195
* TSL object that represents the transformed vertex normal in world space of the current rendered object.

0 commit comments

Comments
 (0)