What is the point of AtlasTexture?

Godot Version

4.5.1

Question

What is the point of using an AtlasTexture? I can set a texture to sample from, set a region and margin. But when I actually try to use the atlas texture, it just gives the entire texture instead of the sampled region that I define. At least that is the behavior I observe with the following:

@onready var atlas : AtlasTexture = preload(“res://textures/atlas/test.tres”);

topMaterial.set_shader_parameter(“gridTexture”, atlas);

# snippet from the shader 
void fragment() {
    ALBEDO = texture(gridTexture, UV).rgb;
}

and I can see in the inspector that the region I define is sampling the proper area from the texture.

For canvas item shaders you can use REGION_RECT built in if the texture is assigned as node’s default texture accessible by TEXTURE (sprites, texture rects and similar). For spatials, afaik, you’ll need to supply the uv region yourself via a uniform.

1 Like