|
@@ -1,5 +1,5 @@
|
|
export default /* glsl */`
|
|
export default /* glsl */`
|
|
-float faceDirection = 1.0;
|
|
|
|
|
|
+float faceDirection = float( gl_FrontFacing ) * 2.0 - 1.0;
|
|
|
|
|
|
#ifdef FLAT_SHADED
|
|
#ifdef FLAT_SHADED
|
|
|
|
|
|
@@ -9,24 +9,12 @@ float faceDirection = 1.0;
|
|
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
|
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
|
|
|
|
- faceDirection = sign( dot( vec3( 0, 0, 1 ), normal ) );
|
|
|
|
-
|
|
|
|
#else
|
|
#else
|
|
|
|
|
|
vec3 normal = normalize( vNormal );
|
|
vec3 normal = normalize( vNormal );
|
|
|
|
|
|
#ifdef DOUBLE_SIDED
|
|
#ifdef DOUBLE_SIDED
|
|
|
|
|
|
- // Workaround for Adreno GPUs not able to do dFdx( vViewPosition )
|
|
|
|
-
|
|
|
|
- vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
|
|
|
|
- vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
|
|
|
-
|
|
|
|
- // Workaround for Adreno GPUs broken gl_FrontFacing implementation
|
|
|
|
- // https://stackoverflow.com/a/32621243
|
|
|
|
-
|
|
|
|
- faceDirection = sign( dot( normal, normalize( cross( fdx, fdy ) ) ) );
|
|
|
|
-
|
|
|
|
normal = normal * faceDirection;
|
|
normal = normal * faceDirection;
|
|
|
|
|
|
#endif
|
|
#endif
|