2011-11-30 11:56:04 -05:00
|
|
|
uniform sampler2D tex_layout;
|
|
|
|
uniform sampler2D tex_detail0;
|
|
|
|
uniform sampler2D tex_detail1;
|
2011-11-30 14:34:37 -05:00
|
|
|
uniform sampler2D tex_detail2;
|
|
|
|
uniform sampler2D tex_detail3;
|
2014-01-18 13:03:10 -05:00
|
|
|
uniform sampler2D DiffuseMap;
|
|
|
|
uniform sampler2D SpecularMap;
|
|
|
|
uniform sampler2D SSAO;
|
|
|
|
uniform vec3 ambient;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-05-16 20:39:55 -04:00
|
|
|
layout (std140) uniform MatrixesData
|
|
|
|
{
|
|
|
|
mat4 ViewMatrix;
|
|
|
|
mat4 ProjectionMatrix;
|
|
|
|
mat4 InverseViewMatrix;
|
|
|
|
mat4 InverseProjectionMatrix;
|
|
|
|
mat4 ShadowViewProjMatrixes[4];
|
|
|
|
vec2 screen;
|
|
|
|
};
|
|
|
|
|
2014-02-28 11:29:05 -05:00
|
|
|
#if __VERSION__ >= 130
|
2014-01-08 19:17:28 -05:00
|
|
|
in vec2 uv;
|
|
|
|
in vec2 uv_bis;
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
2014-02-28 11:29:05 -05:00
|
|
|
#else
|
|
|
|
varying vec2 uv;
|
|
|
|
varying vec2 uv_bis;
|
|
|
|
#define FragColor gl_FragColor
|
|
|
|
#endif
|
|
|
|
|
2013-12-18 19:13:17 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main() {
|
|
|
|
// Splatting part
|
2014-01-19 12:53:35 -05:00
|
|
|
vec4 splatting = texture(tex_layout, uv_bis);
|
|
|
|
vec4 detail0 = texture(tex_detail0, uv);
|
|
|
|
vec4 detail1 = texture(tex_detail1, uv);
|
|
|
|
vec4 detail2 = texture(tex_detail2, uv);
|
|
|
|
vec4 detail3 = texture(tex_detail3, uv);
|
2013-11-30 16:33:06 -05:00
|
|
|
vec4 detail4 = vec4(0.0);
|
|
|
|
|
2014-01-18 13:03:10 -05:00
|
|
|
vec4 splatted = splatting.r * detail0 +
|
2013-11-30 16:33:06 -05:00
|
|
|
splatting.g * detail1 +
|
|
|
|
splatting.b * detail2 +
|
2014-07-12 15:25:11 -04:00
|
|
|
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-18 13:03:10 -05:00
|
|
|
vec2 tc = gl_FragCoord.xy / screen;
|
2014-01-19 12:53:35 -05:00
|
|
|
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
|
|
|
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
|
|
|
float ao = texture(SSAO, tc).x;
|
2014-01-18 13:03:10 -05:00
|
|
|
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(splatted.xyz * LightFactor, 1.);
|
2011-11-30 11:56:04 -05:00
|
|
|
}
|