in vec2 texCoord;
out vec4 fragColor;

uniform sampler2D texture0;
uniform vec4 color;

uniform float farmerState;
uniform float farmerInterval;
uniform float farmerTime;
uniform float alphaThreshold;

void main() {
    float frame = mod(floor(farmerTime / max(farmerInterval, 0.001)), 2.0);

    float yOffset;
    if (farmerState < 0.5) {
        yOffset = 0.5;                           
    } else if (farmerState < 1.5) {
        yOffset = (frame < 0.5) ? 0.0 : -0.25;  
    } else {
        yOffset = (frame < 0.5) ? -0.5 : -0.75; 
    }

    vec2 uv = vec2(texCoord.x, texCoord.y + yOffset);
    vec4 texColor = texture(texture0, uv);

    if (texColor.a < alphaThreshold) discard;

    fragColor = texColor * color*1.5;
}
