How do I convert a node's local position into UV coordinates?

Godot Version

4.5.1

Question

How do I convert a node’s local position into UV coordinates?

gd script code:

gdshader code:

The node using this shader is a ColorRect; the UV position converted with the following code is incorrect.
gdshader code:
mouse_uv=mouse_local_pos*TEXTURE_PIXEL_SIZE;

Normalize what you pass to the shader to 0-1 range:

material.set_shader_parameter("mouse_local_pos", event.position / size)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.