Fixed shaders to be SPIR-V compatible, added a script that converts
[demo] / shaders / morphing.f.glsl
1 #version 450
2
3 #define SHADING_UNIFORMS 1
4
5 layout(binding = 0) uniform sampler2D tex;
6 layout(binding = 1) uniform samplerCube dstex;
7
8 layout(std140, binding = SHADING_UNIFORMS) uniform fu {
9         vec4 diffuse;
10         vec4 specular;
11         float shininess;
12         float fog_density;
13 } s;
14
15 /* varyings */
16 layout(location = 4) in vec3 pos;
17 layout(location = 5) in vec2 tex_coord;
18 layout(location = 6) in vec3 world_normal; 
19
20 layout(location = 0) out vec4 color;
21
22 const vec3 sky_color = vec3(0.35, 0.5, 0.65);
23
24 void main()
25 {
26         vec4 itexel = texture(dstex, normalize(world_normal));
27         vec4 texel = texture(tex, tex_coord);
28         vec3 object_color = s.diffuse.xyz * texel.xyz * itexel.xyz;
29         float dist = -pos.z;
30         float fog = clamp(exp(-s.fog_density * dist), 0.0, 1.0);
31
32         color.xyz = mix(sky_color, object_color, fog);
33         color.w = 1.0;
34 }