How to transform screen position to local texture pixel coordinates

Hi, I have a problem while trying to make a simple pixel art system for the player using Texture2D and SetPixel. SetPixel works by giving it the pixel coordinates of the pixel you want to draw, how can I transform Input.mousePosition to the local pixel coords of the pixel inside the Texture2D?

there is example here using raycast (requires collider on the target)