now we have UBOs/GLSL450 we can use the same shaders for every backend
[demo] / shaders / morphing.v.glsl
diff --git a/shaders/morphing.v.glsl b/shaders/morphing.v.glsl
new file mode 100644 (file)
index 0000000..80b7e39
--- /dev/null
@@ -0,0 +1,44 @@
+#version 450
+
+#define MATRIX_UNIFORMS 0
+#define MORPHING_UNIFORMS 3
+
+layout(std140, binding = MATRIX_UNIFORMS) uniform vu {
+       mat4 mview;
+       uniform mat4 mmviewproj;
+       uniform mat4 mmod;
+} m;
+
+layout(std140, binding = MORPHING_UNIFORMS) uniform mvu {
+       float t;
+} time;
+
+/* attributes */
+layout(location = 1) in vec3 attr_pos;
+layout(location = 2) in vec3 attr_normal;
+layout(location = 3) in vec2 attr_tex;
+
+/* varyings */
+layout(location = 4) out vec3 pos;
+layout(location = 5) out vec2 tex_coord;
+layout(location = 6) out vec3 world_normal; 
+
+const float half_height = 0.855;
+
+void main()
+{
+       vec3 sph_pos = normalize(vec3(attr_pos.x, attr_pos.y - half_height, attr_pos.z));
+
+       vec3 sph_normal = sph_pos;
+       sph_pos.y += half_height;
+
+       vec3 p = mix(attr_pos, sph_pos, time.t);
+       vec3 n = mix(attr_normal, sph_normal, time.t);
+
+       gl_Position = m.mmviewproj * vec4(p, 1.0);
+
+       pos = (m.mview * vec4(p, 1.0)).xyz;
+
+       tex_coord = attr_tex;
+       world_normal = (m.mmod * vec4(attr_normal, 1.0)).xyz;
+}