if you're using Unity and are needing to convert screen space mouse coordinates to your 64x64 render texture's space, here's a script you can use! You need to make sure it's set up properly as per the comments, but other than that it'll deal with changes in screen size too. If you really need the performance (you probably don't), you can move everything above pos = Input.mousePosition;
into Awake
or Start
, but it will cause issues if the screen size changes mid-game
example usage:
[SerializeField] private GetMousePos mousePos; [SerializeField] private Camera cam; void Update () { if (Physics.Raycast(cam.ScreenPointToRay(mousePos.pos), out var hit)) { // do something } }