#version 150

uniform sampler2D t0, tg1, ts;

void main(void) {
	ivec2 tc = ivec2(gl_FragCoord.xy);
	vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, tc, 0), vs = texelFetch(ts, tc, 0);
	float rad;
	float coeff = clamp(modf(v0.w, rad) * 1.1, 0., 1.);
	float reflectivity = 0.;
	float specularity = modf(vg1.w, reflectivity);
	reflectivity = clamp(reflectivity / 100., 0., 1.);
	qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
	//qgl_FragData[0].rgb = vec3(v0.w);
}
