shader_type spatial;

uniform sampler2D door_texture : source_color, filter_nearest, repeat_enable;
uniform vec3 uv_scale = vec3(3.0, 2.0, 3.0);

varying float is_back_face;

void vertex() {
	// NORMAL is in model space here. The -Z face has NORMAL.z == -1.
	is_back_face = step(NORMAL.z, -0.5);
}

void fragment() {
    vec2 uv = UV * uv_scale.xy;
    if (is_back_face > 0.5) {
        uv.x = -uv.x;
    }
    ALBEDO = texture(door_texture, uv).rgb;
}
