

#extension GL_ARB_shader_texture_lod : enable

#include "/lib/taa/res_params.glsl"
varying vec4 lmtexcoord;
varying vec4 color;

uniform sampler2D texture;

#include "/lib/projections.glsl"
#include "/lib/uniforms.glsl"

// faster and actually more precise than pow 2.2
vec3 toLinear(vec3 sRGB)
{
    return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
float luma(vec3 color)
{
    return dot(color, vec3(0.299, 0.587, 0.114));
}

/* RENDERTARGETS: 0,12 */
void main()
{

    vec4 albedo = texture(texture, lmtexcoord.xy, 0);
    if (luma(albedo.rgb) == 0 || albedo.a == 0)
        discard;
    albedo.rgb = toLinear(albedo.rgb * color.rgb);
    vec3 light = vec3(lmtexcoord.zw, color.a);

    gl_FragData[0] = albedo; // Albedo

    gl_FragData[1] = vec4(0, 1, 0, 0.07);
}
