fireball/lib/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl

20 lines
483 B
Plaintext
Raw Normal View History

2018-12-25 13:59:22 +00:00
#ifdef FLAT_SHADED
// Workaround for Adreno/Nexus5 not able 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 ) );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#endif
#endif