#include "/lib/all_the_libs.glsl"

uniform sampler2D lightmap;
uniform sampler2D gtexture;

#define COLORED_SHADOWS 1 //0: Stained glass will cast ordinary shadows. 1: Stained glass will cast colored shadows. 2: Stained glass will not cast any shadows. [0 1 2]
#define SHADOW_BRIGHTNESS 0. //Light levels are multiplied by this number when the surface is in shadows [0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00]

varying vec2 texcoord;
varying vec4 glcolor;
varying vec2 LightmapCoords;


#include "/global/lighting.fsh"
#include "/lib/distort.glsl"

const bool shadowcolor0Nearest = true;
const bool shadowtex0Nearest = true;
const bool shadowtex1Nearest = true;



void main() {

    #ifdef DISTANT_HORIZONS
    vec3 ScreenPos = vec3(gl_FragCoord.xy*resolutionInv, gl_FragCoord.z);
	vec3 ViewPos = to_view_pos(ScreenPos, false);
    vec3 PlayerPos = to_player_pos(ViewPos);

    float Dither = bayer8(gl_FragCoord.xy);
    if (transition_to_dh(PlayerPos, false, Dither)) {
        discard;
        return;
    }
    #endif

    vec4 color = texture2D(gtexture, texcoord) * glcolor;
    color.rgb = to_linear(color.rgb);

    

    vec3 TweakedLM = tweak_lightmap();
    color.xyz *= TweakedLM;
	/* DRAWBUFFERS:0 */
    gl_FragData[0] = color;
}
