+4 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.

asked Apr 14, 2018 in Engine by t17dr (16 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: https://github.com/godotengine/godot/issues/19800

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 How to use this Q&A? before posting your first questions.