Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please make it easier to use World Space Coordinates in Canvas Shaders and/or document the current working approach. #7860

Closed
simonschreibt-code opened this issue Aug 29, 2023 · 1 comment · Fixed by godotengine/godot#81160
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation enhancement
Milestone

Comments

@simonschreibt-code
Copy link

simonschreibt-code commented Aug 29, 2023

Your Godot version:
4.1.1

Issue description:
Accessing World Space based Vertex/Pixel Positions should "just work" (for example, by using a pre-defined keyword like POSITION_WP or similar).
Also a problem: There are many posts on the internet which ask for this and there are many workarounds which don't work anymore in 4.x. For this case, it would be nice if the documentation would give a full example (vertex + fragment shader). In the URL below you'll find an example for the vertex shader but it would be nice to add the fragment shader for example:


varying vec2 world_position;

void vertex() {
	world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}

void fragment() {
	vec2 UV_in_world_space = world_position.xy;
}

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/canvas_item_shader.html

@clayjohn
Copy link
Member

I think it's time for us to revisit adding a world_vertex_coord render mode to 2D like we have for 3D (see godotengine/godot#19800)

The idea was rejected for 3.x as there were some awkward edge cases. But these have been resolved in Godot 4, so there is nothing stopping us now.

Cc @paddy-exe who may be interested in this

@Calinou Calinou added the area:manual Issues and PRs related to the Manual/Tutorials section of the documentation label Aug 30, 2023
@akien-mga akien-mga added this to the 4.2 milestone Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants