
varying vec2 texcoord;
varying vec4 color;


// Standard distortion function
vec3 Distort(vec3 position) {
    // Calculate distance from center (0,0 is the player's position in shadow clip space)
    float centerDist = length(position.xy);
    
    // Create a distortion factor. 
    // The 0.1 protects against division by zero and extreme distortion at the very center.
    float distortion = centerDist + 0.1; 
    
    // Divide XY by the distortion factor to "pull" vertices toward the center
    return vec3(position.xy / distortion, position.z * 0.5); 
}

void main() {
    gl_Position = ftransform();
    texcoord = gl_MultiTexCoord0.xy;
    color=gl_Color;
    gl_Position.xyz = Distort(gl_Position.xyz);
}