#version 330 core
layout (location = 0) in vec3 vin;
layout (location = 1) in vec2 vtx;
invariant gl_Position;

uniform mat4 MVP;

out float depth;

out vec3 FragPos;

void main() {
    gl_Position = MVP * vec4(vin, 1.0);

    // stencil mode
    //depth = 1;
    //if(gl_Position.z<-50) {
    //    depth = -1;
    //}

    // depth mode
    depth = gl_Position.z;
    //depth = ((gl_DepthRange.diff * (gl_Position.z / glPosition.w)) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;

    FragPos = vec3(MVP * vec4(vin, 1.0));
    //depth = gl_Position.z / gl_Position.w; // Linearize if need
}
