Skip to content

Commit aff19fe

Browse files
committed
Document textureSize() should be avoided in Built-in functions
For performance reasons, it's best to pass the texture size as a uniform instead.
1 parent 4bb75ac commit aff19fe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tutorials/shaders/shader_reference/canvas_item_shader.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ is usually:
127127
+--------------------------------+----------------------------------------------------------------+
128128
| in vec2 **TEXTURE_PIXEL_SIZE** | Normalized pixel size of the default 2D texture. |
129129
| | For a Sprite2D with a texture of size 64x32px, |
130-
| | **TEXTURE_PIXEL_SIZE** = ``vec2(1/64, 1/32)`` |
130+
| | **TEXTURE_PIXEL_SIZE** = ``vec2(1.0/64.0, 1.0/32.0)`` |
131131
+--------------------------------+----------------------------------------------------------------+
132132
| inout vec2 **VERTEX** | Vertex position, in local space. |
133133
+--------------------------------+----------------------------------------------------------------+

tutorials/shaders/shader_reference/shader_functions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,9 +2254,9 @@ Texture functions
22542254
+------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
22552255
| | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler2D| s, int lod) | Get the size of a texture. |
22562256
| | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ samplerCube s, int lod) | |
2257-
| | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ samplerCubeArray s, int lod) | |
2258-
| | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler2DArray| s, int lod) | |
2259-
| | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler3D| s, int lod) | |
2257+
| | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ samplerCubeArray s, int lod) | For performance reasons, this function should be avoided as it |
2258+
| | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler2DArray| s, int lod) | always performs a full texture read. When possible, you should pass |
2259+
| | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler3D| s, int lod) | the texture size as a uniform instead. |
22602260
+------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
22612261
| | vec2 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ |gsampler2D| s, vec2 p) | Compute the level-of-detail that would be used to sample from a |
22622262
| | vec3 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ |gsampler2DArray| s, vec2 p) | texture. |

0 commit comments

Comments
 (0)