Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-05-16 09:57:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-05-16 09:57:26 +0300
commit6c951fbd348f56decfa6682c8f490d5872eecb71 (patch)
treecf584207c2ec3b25de815cc3dbbe6e894fc37e4d /source/blender/gpu/shaders
parent2fa2814c8228d07a5bfc8dc7bb0945217ab29b63 (diff)
GPU: use ifdef for flat shader
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_normal_flat_color_vert.glsl26
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_normal_smooth_color_vert.glsl10
-rw-r--r--source/blender/gpu/shaders/gpu_shader_simple_lighting_flat_color_frag.glsl17
-rw-r--r--source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl10
4 files changed, 20 insertions, 43 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_normal_flat_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_normal_flat_color_vert.glsl
deleted file mode 100644
index 8665cb795bc..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_3D_normal_flat_color_vert.glsl
+++ /dev/null
@@ -1,26 +0,0 @@
-
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat3 NormalMatrix;
-
-#if __VERSION__ == 120
- attribute vec3 pos;
- attribute vec3 nor;
- attribute vec4 color;
-
- flat varying vec4 finalColor;
- flat varying vec3 normal;
-#else
- in vec3 pos;
- in vec3 nor;
- in vec4 color;
-
- flat out vec3 normal;
- flat out vec4 finalColor;
-#endif
-
-void main()
-{
- normal = normalize(NormalMatrix * nor);
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- finalColor = color;
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_normal_smooth_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_normal_smooth_color_vert.glsl
index 9eacd10d69e..e29cfd5ab1c 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_normal_smooth_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_normal_smooth_color_vert.glsl
@@ -7,15 +7,25 @@ uniform mat3 NormalMatrix;
attribute vec3 nor;
attribute vec4 color;
+# ifdef USE_FLAT_NORMAL
+ flat varying vec4 finalColor;
+ flat varying vec3 normal;
+# else
varying vec4 finalColor;
varying vec3 normal;
+# endif
#else
in vec3 pos;
in vec3 nor;
in vec4 color;
+# ifdef USE_FLAT_NORMAL
+ flat out vec3 normal;
+ flat out vec4 finalColor;
+# else
out vec3 normal;
out vec4 finalColor;
+# endif
#endif
void main()
diff --git a/source/blender/gpu/shaders/gpu_shader_simple_lighting_flat_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_simple_lighting_flat_color_frag.glsl
deleted file mode 100644
index d93d0532651..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_simple_lighting_flat_color_frag.glsl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-uniform vec3 light;
-
-#if __VERSION__ == 120
- flat varying vec3 normal;
- flat varying vec4 finalColor;
- #define fragColor gl_FragColor
-#else
- flat in vec3 normal;
- flat in vec4 finalColor;
- out vec4 fragColor;
-#endif
-
-void main()
-{
- fragColor = finalColor * max(0.0, dot(normalize(normal), light));
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl
index 260539f76d7..e0d122aa57a 100644
--- a/source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl
@@ -2,12 +2,22 @@
uniform vec3 light;
#if __VERSION__ == 120
+# ifdef USE_FLAT_NORMAL
+ flat varying vec3 normal;
+ flat varying vec4 finalColor;
+# else
varying vec3 normal;
varying vec4 finalColor;
+# endif
#define fragColor gl_FragColor
#else
+# ifdef USE_FLAT_NORMAL
+ flat in vec3 normal;
+ flat in vec4 finalColor;
+# else
in vec3 normal;
in vec4 finalColor;
+# endif
out vec4 fragColor;
#endif