Skip to content

Commit 0d8d4ba

Browse files
authored
Merge pull request #21205 from mrdoob/glfrontfacing
ShaderChunk: Bring gl_FrontFacing back
2 parents e57246b + 9162c7b commit 0d8d4ba

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default /* glsl */`
2-
float faceDirection = 1.0;
2+
float faceDirection = float( gl_FrontFacing ) * 2.0 - 1.0;
33
44
#ifdef FLAT_SHADED
55
@@ -9,24 +9,12 @@ float faceDirection = 1.0;
99
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
1010
vec3 normal = normalize( cross( fdx, fdy ) );
1111
12-
faceDirection = sign( dot( vec3( 0, 0, 1 ), normal ) );
13-
1412
#else
1513
1614
vec3 normal = normalize( vNormal );
1715
1816
#ifdef DOUBLE_SIDED
1917
20-
// Workaround for Adreno GPUs not able to do dFdx( vViewPosition )
21-
22-
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
23-
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
24-
25-
// Workaround for Adreno GPUs broken gl_FrontFacing implementation
26-
// https://stackoverflow.com/a/32621243
27-
28-
faceDirection = sign( dot( normal, normalize( cross( fdx, fdy ) ) ) );
29-
3018
normal = normal * faceDirection;
3119
3220
#endif

src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default /* glsl */`
1212
1313
#ifdef DOUBLE_SIDED
1414
15-
// We can't compute faceDirection if the model doesn't have normals
16-
17-
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
15+
normal = normal * faceDirection;
1816
1917
#endif
2018

0 commit comments

Comments
 (0)