Thank you so much for pointing me in the right direction! That fixed the zoom problem… almost. There is still a small change in color when zooming that I don’t know how to get rid of. See this video.
Flooring the pixel value instead of converting it to an int fixes the issue around the x and y axis.
There is one more small issue: the first pixel lands on the x-y-axis:
I would prefer for it to be next to the axis.
Also worth noting is that if the stretch mode is set to canvas_item, we cannot use get_viewport().global_canvas_transform.get_scale() to get the zoom, as it is always 1.0. Instead we must do:
var zoom_2d: Vector2 = Vector2(get_viewport().size) / get_viewport_rect().size
var zoom: float = min(zoom_2d.x, zoom_2d.y)
I tried using the sub pixel perfect shader, but it did not make a noticeable difference. Using the filter option filter_linear_mipmap did make it near perfect however.
did your sprite in which you add shader material on has been scaled?
or it’s perfectly 1,1 scale in size?
i have a hunch that you might need to send this newly scale parameter of the current sprite into the shader so it doesnt have that flicker
never mind, any sprite/textures can fit into that canvas group, so your sprite will always might not be the same scale, and the shader should never know the scale of each of the item inside it.
Yeah, that shouldn’t matter. And changing the scale of the CanvasGroup doesn’t make a difference either.
It is good enough now however, really it’s barely noticeable. Thank you so much for your help!
The only thing that is annoying me now is that I can’t get the first pixel to land next to the x-y-axis, instead of on it…