Changed the OpenGL part and the GLSL shaders to use UBO and
[demo] / vk_shaders / morphing.f.glsl
1 #version 450
2
3 layout(binding = 0) uniform sampler2D tex;
4 layout(binding = 0) uniform samplerCube dstex;
5
6 layout(std140, binding = 0) uniform shading_state {
7         vec4 diffuse;
8         float fog_density;
9 } s;
10
11 const vec3 sky_color = vec3(0.35, 0.5, 0.65);
12
13 layout(location = 0) in vec3 pos;
14 layout(location = 1) in vec2 tex_coord;
15 layout(location = 2) in vec3 world_normal;
16
17 layout(location = 0) out vec4 color;
18
19 void main()
20 {
21         vec4 itexel = texture(dstex, normalize(world_normal));
22         vec4 texel = texture(tex, tex_coord);
23
24         vec3 object_color = s.diffuse.xyz * texel.xyz * itexel.xyz;
25         float dist = -pos.z;
26         float fog = clamp(exp(-s.fog_density * dist), 0.0, 1.0);
27
28         color.xyz = mix(sky_color, object_color, fog);
29         color.w = 1.0;
30 }