3 layout(binding = 0) uniform sampler2D tex;
4 layout(binding = 0) uniform samplerCube dstex;
6 layout(std140, binding = 0) uniform shading_state {
13 layout(location = 0) in vec3 pos;
14 layout(location = 1) in vec2 tex_coord;
15 layout(location = 2) in vec3 world_normal;
17 // const float fog_density = 0.005;
18 const vec3 sky_color = vec3(0.35, 0.5, 0.65);
20 layout(location = 0) out vec4 color;
24 /*vec4 itexel = textureCube(dstex, normalize(world_normal)); */
25 vec4 itexel = texture(dstex, normalize(world_normal));
27 /* vec3 p = normalize(pos); // view space dir
28 vec3 n = normalize(normal);
29 vec3 l = normalize(ldir);
31 vec3 r = normalize(-reflect(l, n));
32 vec3 vdir = normalize(-p);
34 float cdiff = max(dot(l, n), 0.0);
35 float cspec = pow(max(dot(r, vdir), 0.0), shininess);
39 float fog = clamp(exp(-s.fog_density * dist), 0.0, 1.0);
41 vec4 texel = texture(tex, tex_coord);
43 // vec3 object_color = (diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec) * itexel.xyz;
44 vec3 object_color = s.diffuse.xyz * texel.xyz * itexel.xyz;
46 color.xyz = mix(sky_color, object_color, fog);