now we have UBOs/GLSL450 we can use the same shaders for every backend
[demo] / shaders / morphing.f.glsl
diff --git a/shaders/morphing.f.glsl b/shaders/morphing.f.glsl
new file mode 100644 (file)
index 0000000..de6dda9
--- /dev/null
@@ -0,0 +1,34 @@
+#version 450
+
+#define SHADING_UNIFORMS 1
+
+layout(binding = 0) uniform sampler2D tex;
+layout(binding = 1) uniform samplerCube dstex;
+
+layout(std140, binding = SHADING_UNIFORMS) uniform fu {
+       vec4 diffuse;
+       vec4 specular;
+       float shininess;
+       float fog_density;
+} s;
+
+/* varyings */
+layout(location = 4) in vec3 pos;
+layout(location = 5) in vec2 tex_coord;
+layout(location = 6) in vec3 world_normal; 
+
+layout(location = 0) out vec4 color;
+
+const vec3 sky_color = vec3(0.35, 0.5, 0.65);
+
+void main()
+{
+       vec4 itexel = textureCube(dstex, normalize(world_normal));
+       vec4 texel = texture2D(tex, tex_coord);
+       vec3 object_color = s.diffuse.xyz * texel.xyz * itexel.xyz;
+       float dist = -pos.z;
+       float fog = clamp(exp(-s.fog_density * dist), 0.0, 1.0);
+
+       color.xyz = mix(sky_color, object_color, fog);
+       color.w = 1.0;
+}