#version 330 compatibility
// version 400 was released in 2010. https://en.wikipedia.org/wiki/OpenGL_Shading_Language


//uniform mat4 depthMVP;

uniform sampler2D Texture1; // need
uniform bool uDebugShadowmap;

// Ouput data
//layout(location = 0) out float fragmentdepth;
in vec4 compat_TexCoord;

void main() {
    
    vec4 color = texture(Texture1, compat_TexCoord.st);
    
    // Alpha channel threshhold: at which point transparent stuff should go into depth buffer in shadow pass
    if (color.a < 0.05) {
    	discard;
    }
    
    // Not really needed, OpenGL does it anyway
    //fragmentdepth = gl_FragCoord.z;
    
    if (uDebugShadowmap) {
    	
    	gl_FragColor = color; 
    	
    } else {
    	
    	gl_FragColor = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z); // just alpha
    	
    	//gl_FragDepth = gl_FragCoord.z; // <- don't do this, this totally fucks up intel rendering
    	
    }
    
}
