stk-code_catmod/data/shaders/caustics.frag

33 lines
883 B
GLSL
Raw Normal View History

2014-03-04 16:30:33 -05:00
uniform sampler2D Albedo;
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
uniform sampler2D caustictex;
uniform vec2 dir;
uniform vec2 dir2;
2014-03-04 16:30:33 -05:00
#if __VERSION__ >= 130
2014-03-04 12:42:33 -05:00
in vec2 uv;
out vec4 FragColor;
2014-03-04 16:30:33 -05:00
#else
varying vec2 uv;
#define FragColor gl_FragColor
#endif
void main()
{
2014-03-04 16:30:33 -05:00
vec2 tc = gl_FragCoord.xy / screen;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
vec4 color = texture(Albedo, uv);
float ao = texture(SSAO, tc).x;
2014-03-04 16:30:33 -05:00
float caustic = texture(caustictex, uv + dir).x;
float caustic2 = texture(caustictex, (uv.yx + dir2 * vec2(-0.6, 0.3)) * vec2(0.6)).x;
2014-03-04 16:30:33 -05:00
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent + caustic * caustic2 * 10;
FragColor = vec4(color.xyz * LightFactor, 1.);
}