Godot Version
4.5
Question
I’m new to shaders and having a very hard time creating a shader that applies to a region of an AtlasTexture. UV refers to the entire texture. Supposedly, I can use REGION_RECT to get around this, but I cannot for the life of me understand how. I’ve tried utilizing the example provided in the PR: https://github.com/godotengine/godot/pull/90436#issuecomment-2776191472, but either I’m utterly misunderstanding it or it’s just not applicable code to my use-case.
vec2 uv_region = (UV - REGION_RECT.xy) / REGION_RECT.zw; gives me the whole texture, squashed. JUST vec2 uv_region = (UV - REGION_RECT.xy); seems to return the region starting at 0, 0 (aka the top left corner) instead of the one specified.
I can’t find any other examples of it’s use; from what I understand it’s new to 4.5, so that’s understandable. Can anyone explain to me how I can use it to get the UV of just that region? Also, are both these inspector region editors applicable for REGION_RECT? It’s a bit confusing that there’s one that’s part of the AtlasTexture resource and then another entirely separate one that does the same thing.


