Godot Version
Godot 4.3
Question
I’m making a game similar to stackland and I’ve been trying to replicate the slightly skewed prespective of the game world using this shader
and this is my node setup, the shader was placed on the SubviewportContainer
node

i thought it worked flawlessly,
but then I change the camera zoom and I noticed that the global position is different from the actual position because of the shader. and it only position correctly when it’s at the center of the screen.
My question is how do I make it so the position works correctly even after the shader was applied? I’m new to shader stuff so I’m not sure how to modify them myself, if that’s needed, thank you.
PS: the godot icon there is to check if the global mouse position is misaligned or not.
Can you please share the code, how you access the global position? It is likely that you need the position in a different coordinate system and seeing, how you access it would help to identify the necessary changes.
it is simply
global_position = get_global_mouse_position()
this works perfectly without shader
get_global_mouse_position()
returns the mouse position in the canvas. As far as I can tell, you seem to need the mouse position in the coordinate system of the respective Node2D.
Have you tried to use get_local_mouse_position()
?
This topic is covered in the docs here: Viewport and canvas transforms — Godot Engine (4.3) documentation in English
This is less related to the shader but is rather caused by the camera zoom.
I’ve tried to play with the position stuff but no good result. So I was checking if the shader was the problem (turns out it was and it happens even without zoom).
My assumption is the skew messes up with the mouse position in the canvas item, i just want to have a conversion for the global position and the canvasitem that was applied the shader
These are the screenshot without zoom, the same problem presist (The mouse position is offset slightly in the corner of the screen, it was suppose to be on the nose of the godot icon)