]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/parentheses.glsl
Remove the ParenthesizedExpression node type
[libs/gl.git] / tests / glsl / parentheses.glsl
diff --git a/tests/glsl/parentheses.glsl b/tests/glsl/parentheses.glsl
new file mode 100644 (file)
index 0000000..9899c49
--- /dev/null
@@ -0,0 +1,69 @@
+struct LightParams
+{
+       uniform vec3 ambient;
+       uniform vec3 color;
+       uniform float intensity;
+       uniform vec3 dir;
+};
+uniform LightParams light;
+uniform vec3 material_color;
+uniform mat4 mvp;
+uniform vec3 offset;
+uniform sampler2D occlusion_map;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+void main()
+{
+       vec4 p = position+vec4(offset, 1.0);
+       gl_Position = mvp*p;
+       passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       float occlusion = float(texture(occlusion_map, texcoord));
+       vec3 light_color = light.color*light.intensity;
+       vec3 l = light.ambient+light_color*max(dot(light.dir, normalize(normal)), 0.0);
+       frag_color = vec4(material_color*l*occlusion, 1.0);
+}
+
+/* Expected output: vertex
+uniform mat4 mvp;
+uniform vec3 offset;
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+out vec3 _vs_out_normal;
+out vec2 _vs_out_texcoord;
+void main()
+{
+       gl_Position = mvp*(position+vec4(offset, 1.0));
+       _vs_out_normal = normal;
+       _vs_out_texcoord = texcoord;
+}
+*/
+
+/* Expected output: fragment
+struct LightParams
+{
+  uniform vec3 ambient;
+  uniform vec3 color;
+  uniform float intensity;
+  uniform vec3 dir;
+};
+uniform LightParams light;
+uniform vec3 material_color;
+uniform sampler2D occlusion_map;
+layout(location=0) out vec4 frag_color;
+in vec2 _vs_out_texcoord;
+in vec3 _vs_out_normal;
+void main()
+{
+       frag_color = vec4(material_color*(light.ambient+light.color*light.intensity*max(dot(light.dir, normalize(_vs_out_normal)), 0.0))*float(texture(occlusion_map, _vs_out_texcoord)), 1.0);
+}
+*/