I have a Godot CanvasItem shader that is assigned to the material of a specific tile in a TileMap. In the shader, I need to know the position of a light relative to the bottom of the tile.
I am computing the bottom right corner like this:
varying vec2 bottom_right_corner;
void vertex() {
vec2 world_vertex_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
bottom_right_corner = floor(world_vertex_position / 32.0 + 1.0) * 32.0;
}
void light() {
// How to compare bottom_right_corner.y with LIGHT_POSITION.y ?
}
I think now I need to apply some transformation to these coordinates so that I can compare them with LIGHT_POSITION
, but I’m not sure which.
How can I perform this comparison?