2014-01-24 14:29:54 -05:00
|
|
|
uniform sampler2D Albedo;
|
|
|
|
uniform sampler2D DiffuseMap;
|
|
|
|
uniform sampler2D SpecularMap;
|
|
|
|
uniform sampler2D SSAO;
|
|
|
|
uniform vec2 screen;
|
|
|
|
uniform vec3 ambient;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-02-28 11:29:05 -05:00
|
|
|
#if __VERSION__ >= 130
|
2014-04-10 11:34:57 -04:00
|
|
|
in vec3 nor;
|
2014-01-24 14:29:54 -05:00
|
|
|
in vec2 uv;
|
|
|
|
out vec4 FragColor;
|
2014-02-28 11:29:05 -05:00
|
|
|
#else
|
2014-04-10 11:34:57 -04:00
|
|
|
varying vec3 nor;
|
2014-02-28 11:29:05 -05:00
|
|
|
varying vec2 uv;
|
|
|
|
#define FragColor gl_FragColor
|
|
|
|
#endif
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
void main() {
|
2014-04-10 11:34:57 -04:00
|
|
|
float rim = 1.0 - dot(nor, vec3(0., 0., -1));
|
2014-04-14 19:56:26 -04:00
|
|
|
rim = smoothstep(0.5, 1.5, rim) * 0.15;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-24 14:29:54 -05:00
|
|
|
vec4 color = texture(Albedo, uv);
|
|
|
|
vec2 tc = gl_FragCoord.xy / screen;
|
|
|
|
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
|
|
|
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
|
|
|
float ao = texture(SSAO, tc).x;
|
|
|
|
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
|
|
|
|
FragColor = vec4(color.xyz * LightFactor + rim, 1.);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|
|
|
|
|