varying vec4 color;
varying vec2 texcoord;
uniform sampler2D texture;
#include "/lib/uniforms.glsl"
varying vec3 np3;
uniform float nightblend5;
uniform vec3 sunPosWorld;
uniform vec3 moonPosWorld;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
vec3 toLinear(vec3 sRGB)
{
    return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
/* RENDERTARGETS: 8 */
float luma(vec3 color)
{
    return dot(color, vec3(0.299, 0.587, 0.114));
}
void main()
{
    vec2 texsize = textureSize(texture, 0);
    vec3 normp3 = normalize(np3);
    float nds = max(dot(normp3, sunPosWorld), 0.0);
    float ndm = max(dot(normp3, moonPosWorld), 0.0);
    float celstswitch = mix(ndm, nds, nightblend5);
    vec2 texcoord0 = texcoord;
    if (texsize.x == texsize.y)
        texcoord0 = clamp(texcoord * 1.5 - 0.25, 0, 1);
    vec4 albedo = texture(texture, texcoord0.xy);

    albedo.rgb = toLinear(albedo.rgb) * 5;
    albedo.a = 0.9*celstswitch;

    // if (luma(albedo.rgb) > 0.0)
    //     albedo.a = 0.9;
    gl_FragData[0] = albedo;
}