2014-01-04 19:08:00 -05:00
|
|
|
#version 130
|
2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D ntex;
|
2014-01-27 14:08:59 -05:00
|
|
|
uniform sampler2D dtex;
|
2014-01-21 17:44:23 -05:00
|
|
|
//uniform sampler2D cloudtex;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-21 17:44:23 -05:00
|
|
|
uniform vec3 direction;
|
2013-11-30 16:33:06 -05:00
|
|
|
uniform vec3 col;
|
2013-12-18 19:13:17 -05:00
|
|
|
uniform mat4 invproj;
|
2014-01-21 17:44:23 -05:00
|
|
|
//uniform int hasclouds;
|
|
|
|
//uniform vec2 wind;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-21 17:44:23 -05:00
|
|
|
in vec2 uv;
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 Diff;
|
|
|
|
out vec4 Spec;
|
|
|
|
out vec4 SpecularMap;
|
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main() {
|
2014-01-27 14:08:59 -05:00
|
|
|
float z = texture(dtex, uv).x;
|
2014-01-21 17:44:23 -05:00
|
|
|
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
|
2013-12-23 12:00:34 -05:00
|
|
|
xpos = invproj * xpos;
|
|
|
|
xpos.xyz /= xpos.w;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
if (z < 0.03)
|
|
|
|
{
|
|
|
|
// Skyboxes are fully lit
|
2014-01-19 13:31:00 -05:00
|
|
|
Diff = vec4(1.0);
|
|
|
|
Spec = vec4(1.0);
|
2013-11-30 16:33:06 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-27 16:21:16 -05:00
|
|
|
vec3 norm = normalize(2. * texture(ntex, uv).xyz - 1.);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
// Normalized on the cpu
|
2014-01-21 17:44:23 -05:00
|
|
|
vec3 L = direction;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
float NdotL = max(0.0, dot(norm, L));
|
2013-12-23 12:00:34 -05:00
|
|
|
vec3 R = reflect(L, norm);
|
2013-12-23 21:47:33 -05:00
|
|
|
float RdotE = max(0.0, dot(R, normalize(xpos.xyz)));
|
2013-12-23 12:00:34 -05:00
|
|
|
float Specular = pow(RdotE, 200);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
vec3 outcol = NdotL * col;
|
|
|
|
|
2014-01-21 17:44:23 -05:00
|
|
|
/* if (hasclouds == 1)
|
2013-11-30 16:33:06 -05:00
|
|
|
{
|
|
|
|
vec2 cloudcoord = (xpos.xz * 0.00833333) + wind;
|
2014-01-19 12:53:35 -05:00
|
|
|
float cloud = texture(cloudtex, cloudcoord).x;
|
2013-11-30 16:33:06 -05:00
|
|
|
//float cloud = step(0.5, cloudcoord.x) * step(0.5, cloudcoord.y);
|
|
|
|
|
|
|
|
outcol *= cloud;
|
2014-01-21 17:44:23 -05:00
|
|
|
}*/
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
Diff = vec4(NdotL * col, 1.);
|
|
|
|
Spec = vec4(Specular * col, 1.);
|
|
|
|
SpecularMap = vec4(1.0);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|