Godot Version
4.7
Question
Hi,
I have been trying to figure out how to get pixels in gdscript in the same way as in a shader.
The Image.get_pixel(x,y) function uses array type coordinates (e.g (0-512)) and the coordinates do not wrap around so a number bigger than 512 causes an error.
so if I had
uv_scale * world_pos.xz / 128.0
in the shader, then I would have something like
512 * int( uv_scale * x / 128.0 )
the uv_scale * x / 128.0 can be 4.0 * 127.0 / 128.0, the x / 128.0 is like a percentage, and the final result is bigger than 512, so I just added the floor() function
512 * int( uv_scale * x / 128.0 - floor( uv_scale * x / 128.0 ))
And a similar function for the v coordinate.
This is still wrong … any help would be appreciated.