2015-04-16 16:55:32 +00:00
|
|
|
#version 330 core
|
|
|
|
//precision highp float;
|
|
|
|
|
|
|
|
in Fragment
|
|
|
|
{
|
|
|
|
vec4 color;
|
|
|
|
} fragment;
|
|
|
|
|
|
|
|
in Vert
|
|
|
|
{
|
|
|
|
vec2 texcoord;
|
|
|
|
} vert;
|
|
|
|
|
|
|
|
uniform sampler2D Diffuse;
|
|
|
|
uniform sampler2DShadow shadowMap;
|
|
|
|
|
|
|
|
in vec3 lightDir,normal,ambient;
|
|
|
|
in vec4 ShadowCoord;
|
|
|
|
|
|
|
|
out vec4 color;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2015-08-06 02:03:27 +00:00
|
|
|
vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);
|
2015-04-16 16:55:32 +00:00
|
|
|
vec3 ct,cf;
|
|
|
|
float intensity,at,af;
|
|
|
|
|
2016-07-14 07:05:57 +00:00
|
|
|
intensity = 0.5+0.5*clamp( dot( normalize(normal),lightDir ), -1,1 );
|
2015-08-06 02:03:27 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
af = 1.0;
|
|
|
|
|
|
|
|
ct = texel.rgb;
|
|
|
|
at = texel.a;
|
|
|
|
|
|
|
|
//float bias = 0.005f;
|
|
|
|
|
2016-10-14 22:06:09 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2016-10-14 22:06:09 +00:00
|
|
|
float visibility = texture(shadowMap, vec3(ShadowCoord.xy,(ShadowCoord.z)/ShadowCoord.w));
|
2017-04-23 14:35:13 +00:00
|
|
|
if (intensity<0.5)
|
|
|
|
visibility = 0;
|
|
|
|
|
2015-08-06 02:03:27 +00:00
|
|
|
intensity = 0.7*intensity + 0.3*intensity*visibility;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-08-06 02:03:27 +00:00
|
|
|
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-08-06 02:03:27 +00:00
|
|
|
color = vec4(ct * cf, fragment.color.w);
|
2015-04-16 16:55:32 +00:00
|
|
|
}
|