Godot Version
4.4.1
Question
Is there a built-in for the Rect’s Size of the Control that the CanvasItem shader is on? In the docs CanvasItem shaders — Godot Engine (stable) documentation in English , I see SCREEN_PIXEL_SIZE, which you can use to find the screen’s aspect ratio, but I’d like to have access to the aspect ratio of the Control’s rect too.
I could use TEXTURE_PIXEL_SIZE, but my shader doesn’t use a texture - I’m applying it to Panels and StyleBoxes
I know I can use a Uniform for this and pass the rect size to it on _ready, but this seems like it would be a great built-in to have for CanvasItem shaders that need to scale the UV by the aspect of the Rect it’s using. Also, my Controls are animated over time, so this uniform would need to be updated frequently via script, which I’d like to avoid.
For context, I’m building a CanvasItem shader that has scrolling, tiled icons. In the screenshot, the sword icons are moving to the right over time. I have it working in Screen Space right now using float screen_aspect = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
I would expect there to be something like RECT_PIXEL_SIZE so you could do:
float control_aspect = RECT_PIXEL_SIZE.x / RECT_PIXEL_SIZE.y;
TLDR: Is there a built-in for the control’s rect size that I’m missing?