2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D ntex;
|
2014-01-27 14:08:59 -05:00
|
|
|
uniform sampler2D dtex;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 Diff;
|
|
|
|
out vec4 Spec;
|
|
|
|
|
2016-06-27 07:11:27 -04:00
|
|
|
#stk_include "utils/decodeNormal.frag"
|
|
|
|
#stk_include "utils/SpecularBRDF.frag"
|
|
|
|
#stk_include "utils/DiffuseBRDF.frag"
|
|
|
|
#stk_include "utils/getPosFromUVDepth.frag"
|
|
|
|
#stk_include "utils/SunMRP.frag"
|
2014-11-20 20:44:27 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main() {
|
2014-06-03 14:28:42 -04:00
|
|
|
vec2 uv = gl_FragCoord.xy / screen;
|
2014-12-14 15:39:18 -05:00
|
|
|
float z = texture(dtex, uv).x;
|
|
|
|
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-12-14 15:39:18 -05:00
|
|
|
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
2014-04-06 16:19:10 -04:00
|
|
|
float roughness = texture(ntex, uv).z;
|
2014-04-06 15:23:09 -04:00
|
|
|
vec3 eyedir = -normalize(xpos.xyz);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-12-21 15:05:41 -05:00
|
|
|
vec3 Lightdir = SunMRP(norm, eyedir);
|
|
|
|
float NdotL = clamp(dot(norm, Lightdir), 0., 1.);
|
2014-11-20 19:54:30 -05:00
|
|
|
|
2014-12-14 15:39:18 -05:00
|
|
|
vec3 Specular = SpecularBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
|
|
|
vec3 Diffuse = DiffuseBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-12-15 17:09:19 -05:00
|
|
|
Diff = vec4(NdotL * Diffuse * sun_col, 1.);
|
|
|
|
Spec = vec4(NdotL * Specular * sun_col, 1.);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
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
|
|
|
}
|