

varying vec2 lmcoord;
varying vec4 glcolor;

#ifdef VSH

    void main() {
        gl_Position = ftransform();
        lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
        lmcoord = clamp(lmcoord, 0.5/16, 15.5/16);
        glcolor = gl_Color;
    }

#endif

#ifdef FSH

    uniform sampler2D lightmap;
    uniform int renderStage;

    uniform float alphaTestRef = 0.1;

    /* RENDERTARGETS: 0 */
    layout(location = 0) out vec4 color;

    void main() {
        if (renderStage == MC_RENDER_STAGE_OUTLINE) {
            color = vec4(1.0, 1.0, 1.0, glcolor.a);
        } else {
            color = glcolor * texture(lightmap, lmcoord);
        }

        if (color.a < alphaTestRef) {
            discard;
        }
    }

#endif