Merge branch 'master' into blender2.8
[blender.git] / source / blender / gpu / shaders / gpu_shader_basic_frag.glsl
index e1cd7e0684c91d19a91bf44e9b738fe619f2b1a0..2f501dfab0547911ecc8dbd483a6cd7d90952260 100644 (file)
 #define STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP        11
 
 #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
 #define STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP        11
 
 #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
+#if defined(USE_FLAT_NORMAL)
+varying vec3 eyespace_vert_pos;
+#else
 varying vec3 varying_normal;
 varying vec3 varying_normal;
-
+#endif
 #ifndef USE_SOLID_LIGHTING
 varying vec3 varying_position;
 #endif
 #ifndef USE_SOLID_LIGHTING
 varying vec3 varying_position;
 #endif
@@ -137,7 +140,11 @@ void main()
 
 #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
        /* compute normal */
 
 #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING)
        /* compute normal */
+#if defined(USE_FLAT_NORMAL)
+       vec3 N = normalize(cross(dFdx(eyespace_vert_pos), dFdy(eyespace_vert_pos)));
+#else
        vec3 N = normalize(varying_normal);
        vec3 N = normalize(varying_normal);
+#endif
 
 #ifdef USE_TWO_SIDED
        if (!gl_FrontFacing)
 
 #ifdef USE_TWO_SIDED
        if (!gl_FrontFacing)