The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+5 votes

From the built-ins FRAGCOORD seems to be a position in window/viewport space. VERTEX is a local position and I wasn't able to correctly use the transform matrices to get world coordinates from it - multiplying VERTEX by WORLD_MATRIX makes the result still dependent on camera position.

in Engine by (17 points)

I see that spatial shaders have a render mode called world_vertex_coords that changes the vertex info (for example, VERTEX) to world space. Not sure if that helps with canvas item shaders though. I do see that canvas item shader have a render mode called skip_vertex_transform, whose description is "VERTEX/NORMAL/etc need to be transformed manually in VS." Maybe you need to set this render mode before you try to transform by the world matrix? Not sure, I'm brand new to shaders.

I have tried that too, but it doesn't seem to change anything:

world_pos = (WORLD_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
VERTEX = (EXTRA_MATRIX * (WORLD_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;

and world_pos still changes when moving the camera.

Did you resolve this? I'm having trouble with this too.

There's a bug report related to this:

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.