]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/constructors.glsl
Resolve and validate the parameters of constructors in GLSL
[libs/gl.git] / tests / glsl / constructors.glsl
diff --git a/tests/glsl/constructors.glsl b/tests/glsl/constructors.glsl
new file mode 100644 (file)
index 0000000..fe7ca48
--- /dev/null
@@ -0,0 +1,58 @@
+uniform mat4 model;
+uniform mat4 view_projection;
+uniform vec3 light_dir;
+uniform sampler2D normalmap;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec3 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec3 tangent;
+layout(location=3) in vec3 binormal;
+layout(location=4) in vec2 texcoord;
+void main()
+{
+       mat3 normal_matrix = mat3(model);
+       mat3 tbn_matrix = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal);
+       out vec3 tbn_light_dir = tbn_matrix*light_dir;
+       gl_Position = view_projection*model*vec4(position, 1);
+       passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       vec3 normal = vec3(texture(normalmap, texcoord))*2.0-1.0;
+       frag_color = vec4(vec3(dot(normal, normalize(tbn_light_dir))), 1);
+}
+
+/* Expected output: vertex
+uniform mat4 model;
+uniform mat4 view_projection;
+uniform vec3 light_dir;
+layout(location=0) in vec3 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec3 tangent;
+layout(location=3) in vec3 binormal;
+layout(location=4) in vec2 texcoord;
+out vec3 tbn_light_dir;
+out vec2 _vs_out_texcoord;
+void main()
+{
+  mat3 normal_matrix = mat3(model[0].xyz, model[1].xyz, model[2].xyz);
+  tbn_light_dir = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal)*light_dir;
+  gl_Position = view_projection*model*vec4(position, float(1));
+  _vs_out_texcoord = texcoord;
+}
+*/
+
+/* Expected output: fragment
+uniform sampler2D normalmap;
+layout(location=0) out vec4 frag_color;
+in vec2 _vs_out_texcoord;
+in vec3 tbn_light_dir;
+void main()
+{
+  frag_color = vec4(vec3(dot(vec3(texture(normalmap, _vs_out_texcoord).xyz)*2.0-1.0, normalize(tbn_light_dir))), float(1));
+}
+*/