Skip to content

Commit 0fc73a7

Browse files
committed
Document REGION_RECT canvas shader built-in
This was added in 4.5 to better accomodate Sprite2D with regions enabled.
1 parent a1632ef commit 0fc73a7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tutorials/shaders/shader_reference/canvas_item_shader.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ CanvasItem shaders
66
CanvasItem shaders are used to draw all 2D elements in Godot. These include
77
all nodes that inherit from CanvasItems, and all GUI elements.
88

9-
CanvasItem shaders contain fewer built-in variables and functionality than
10-
:ref:`Spatial shaders<doc_spatial_shader>`, but they maintain the same basic structure
9+
CanvasItem shaders contain fewer built-in variables and functionality than
10+
:ref:`Spatial shaders<doc_spatial_shader>`, but they maintain the same basic structure
1111
with vertex, fragment, and light processor functions.
1212

1313
Render modes
@@ -223,6 +223,10 @@ it to the ``NORMAL_MAP`` property. Godot will handle converting it for use in 2D
223223
+---------------------------------------------+---------------------------------------------------------------+
224224
| in vec2 **SCREEN_PIXEL_SIZE** | Size of individual pixels. Equal to inverse of resolution. |
225225
+---------------------------------------------+---------------------------------------------------------------+
226+
| in vec4 **REGION_RECT** | Visible area of the sprite region in format |
227+
| | ``(x, y, width, height)``. Varies according to |
228+
| | Sprite2D's ``region_enabled`` property. |
229+
+---------------------------------------------+---------------------------------------------------------------+
226230
| in vec2 **POINT_COORD** | Coordinate for drawing points. |
227231
+---------------------------------------------+---------------------------------------------------------------+
228232
| sampler2D **TEXTURE** | Default 2D texture. |
@@ -238,6 +242,9 @@ it to the ``NORMAL_MAP`` property. Godot will handle converting it for use in 2D
238242
| in vec4 **SPECULAR_SHININESS** | Specular shininess color, as sampled from the texture. |
239243
+---------------------------------------------+---------------------------------------------------------------+
240244
| in vec2 **UV** | UV from the ``vertex()`` function. |
245+
| | For Sprite2D with region enabled, this will sample the entire |
246+
| | texture. Use ``REGION_RECT`` instead to sample only the |
247+
| | region defined in the Sprite2D's properties. |
241248
+---------------------------------------------+---------------------------------------------------------------+
242249
| in vec2 **SCREEN_UV** | Screen UV coordinate for current pixel. |
243250
+---------------------------------------------+---------------------------------------------------------------+

0 commit comments

Comments
 (0)