added IBR lighting from irradiance maps
[demo] / gl_shaders / morphing.f.glsl
1 #version 450
2
3 uniform sampler2D tex;
4 uniform samplerCube dstex;
5
6 uniform vec4 diffuse;
7 // uniform vec4 specular;
8 // uniform float shininess;
9
10 uniform float fog_density;
11 const vec3 sky_color = vec3(0.35, 0.5, 0.65);
12
13 varying vec3 pos;
14 // varying vec3 normal;
15 // varying vec3 ldir;
16 varying vec2 tex_coord;
17 varying vec3 world_normal;
18
19 out vec4 color;
20
21 void main()
22 {
23         vec4 itexel = textureCube(dstex, normalize(world_normal));
24         // vec3 p = normalize(pos);
25         // vec3 n = normalize(normal);
26         // vec3 l = normalize(ldir);
27
28         // vec3 r = normalize(-reflect(l, n));
29         // vec3 vdir = normalize(-p);
30
31         // float cdiff = max(dot(l, n), 0.0);
32         // float cspec = pow(max(dot(r, vdir), 0.0), shininess);
33
34         vec4 texel = texture2D(tex, tex_coord);
35         // vec3 object_color = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec;
36         vec3 object_color = diffuse.xyz * texel.xyz * itexel.xyz;
37         float dist = -pos.z;
38         float fog = clamp(exp(-fog_density * dist), 0.0, 1.0);
39
40         color.xyz = mix(sky_color, object_color, fog);
41         color.w = 1.0;
42 }