From e2a1f4cebe21a0233735bf82458093bf25d7c9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Tue, 1 Apr 2014 10:01:55 +0300 Subject: [PATCH] shaders: glsl-flatshade test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76883 Signed-off-by: Tapani Pälli --- tests/shaders/glsl-flatshade.shader_test | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/shaders/glsl-flatshade.shader_test diff --git a/tests/shaders/glsl-flatshade.shader_test b/tests/shaders/glsl-flatshade.shader_test new file mode 100644 index 0000000..20238a3 --- /dev/null +++ b/tests/shaders/glsl-flatshade.shader_test @@ -0,0 +1,36 @@ +[require] +GLSL >= 1.10 + +[vertex shader] +attribute vec4 vertex; +attribute vec4 normal; +varying float angle_cos; +uniform vec4 light; + +void main() +{ + float light_len = length(light); + float dot_product = dot(normal, light); + angle_cos = dot_product / (length(normal) * light_len); + gl_Position = vertex; +} + +[fragment shader] +varying float angle_cos; + +void main() +{ + vec4 dcolor = vec4(1.0, 0.0, 1.0, 1.0); + + if (angle_cos > 0.0) { + float diffuse = 0.6 * (angle_cos/2.0); + dcolor.r += 2.0 * diffuse * 1.0; + dcolor.g += 2.0 * diffuse * 1.0; + dcolor.b += 2.0 * diffuse * 1.0; + } + + gl_FragColor = dcolor; +} + +[test] +link success -- 1.8.3.1