File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,13 @@ export const transformedNormalView = /*@__PURE__*/ ( Fn( ( builder ) => {
83
83
84
84
// Use getUV context to avoid side effects from nodes overwriting getUV in the context (e.g. EnvironmentNode)
85
85
86
- return builder . context . setupNormal ( ) . context ( { getUV : null } ) ;
86
+ let node = builder . context . setupNormal ( ) . context ( { getUV : null } ) ;
87
87
88
- } , 'vec3' ) . once ( ) ) ( ) . mul ( faceDirection ) . toVar ( 'transformedNormalView' ) ;
88
+ if ( builder . material . flatShading !== true ) node = node . mul ( faceDirection ) ;
89
+
90
+ return node ;
91
+
92
+ } , 'vec3' ) . once ( ) ) ( ) . toVar ( 'transformedNormalView' ) ;
89
93
90
94
/**
91
95
* TSL object that represents the transformed vertex normal in world space of the current rendered object.
@@ -105,9 +109,13 @@ export const transformedClearcoatNormalView = /*@__PURE__*/ ( Fn( ( builder ) =>
105
109
106
110
// Use getUV context to avoid side effects from nodes overwriting getUV in the context (e.g. EnvironmentNode)
107
111
108
- return builder . context . setupClearcoatNormal ( ) . context ( { getUV : null } ) ;
112
+ let node = builder . context . setupClearcoatNormal ( ) . context ( { getUV : null } ) ;
113
+
114
+ if ( builder . material . flatShading !== true ) node = node . mul ( faceDirection ) ;
115
+
116
+ return node ;
109
117
110
- } , 'vec3' ) . once ( ) ) ( ) . mul ( faceDirection ) . toVar ( 'transformedClearcoatNormalView' ) ;
118
+ } , 'vec3' ) . once ( ) ) ( ) . toVar ( 'transformedClearcoatNormalView' ) ;
111
119
112
120
/**
113
121
* Transforms the normal with the given matrix.
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ class FrontFacingNode extends Node {
38
38
39
39
const { renderer, material } = builder ;
40
40
41
+ if ( material . flatShading === true ) return 'true' ;
42
+
41
43
if ( renderer . coordinateSystem === WebGLCoordinateSystem ) {
42
44
43
45
if ( material . side === BackSide ) {
You can’t perform that action at this time.
0 commit comments