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:
authorClément Foucault <foucault.clem@gmail.com>2017-02-07 15:04:08 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-02-11 02:39:09 +0300
commitb4a01e7f4fde191516a6187d781ebdce45cf48b7 (patch)
treea427e25a640cccb2f8b0c351e140870497cbe298 /source/blender/gpu/shaders
parent8fbf1c4d77dcf21f2b7d63db51c7b6a950e21993 (diff)
OpenGL immediate mode: interface_draw.c (cont)
ui_draw_but_COLORBAND Introduced a new checker shader to be used mostly on transparent areas. OpenGL immediate mode: interface_draw.c (cont) ui_draw_but_UNITVEC Introduced a new shader to be used for simple lighting.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_vert.glsl14
-rw-r--r--source/blender/gpu/shaders/gpu_shader_checker_frag.glsl24
-rw-r--r--source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl16
3 files changed, 54 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl
index 32da3a99c63..58150c004e5 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl
@@ -1,13 +1,27 @@
uniform mat4 ModelViewProjectionMatrix;
+#ifdef USE_NORMALS
+uniform mat3 NormalMatrix;
+#endif
#if __VERSION__ == 120
attribute vec3 pos;
+#ifdef USE_NORMALS
+ attribute vec3 nor;
+ varying vec3 normal;
+#endif
#else
in vec3 pos;
+#ifdef USE_NORMALS
+ in vec3 nor;
+ out vec3 normal;
+#endif
#endif
void main()
{
+#ifdef USE_NORMALS
+ normal = normalize(NormalMatrix * nor);
+#endif
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
}
diff --git a/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl b/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl
new file mode 100644
index 00000000000..3b24af916a0
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl
@@ -0,0 +1,24 @@
+
+uniform vec4 color1;
+uniform vec4 color2;
+uniform int size;
+
+#if __VERSION__ == 120
+ #define fragColor gl_FragColor
+#else
+ out vec4 fragColor;
+#endif
+
+void main()
+{
+ vec2 phase = mod(gl_FragCoord.xy, (size*2));
+
+ if ((phase.x > size && phase.y < size) ||
+ (phase.x < size && phase.y > size))
+ {
+ fragColor = color1;
+ }
+ else {
+ fragColor = color2;
+ }
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl b/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl
new file mode 100644
index 00000000000..9828787fb04
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl
@@ -0,0 +1,16 @@
+
+uniform vec4 color;
+uniform vec3 light;
+
+#if __VERSION__ == 120
+ varying vec3 normal;
+ #define fragColor gl_FragColor
+#else
+ in vec3 normal;
+ out vec4 fragColor;
+#endif
+
+void main()
+{
+ fragColor = color * max(0.0, dot(normalize(normal), light));
+}