|
@@ -788,26 +788,88 @@ GDScript uses different variable types than GLSL does, so when passing variables
|
|
from GDScript to shaders, Godot converts the type automatically. Below is a
|
|
from GDScript to shaders, Godot converts the type automatically. Below is a
|
|
table of the corresponding types:
|
|
table of the corresponding types:
|
|
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| GDScript type | GLSL type |
|
|
|
|
-+=================+===========+
|
|
|
|
-| **bool** | **bool** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **int** | **int** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **float** | **float** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **Vector2** | **vec2** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **Vector3** | **vec3** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **Color** | **vec4** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **Transform3D** | **mat4** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-| **Transform2D** | **mat4** |
|
|
|
|
-+-----------------+-----------+
|
|
|
|
-
|
|
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| GLSL type | GDScript type | Notes |
|
|
|
|
++======================+=========================+============================================================+
|
|
|
|
+| **bool** | **bool** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **bvec2** | **int** | Bitwise packed int where bit 0 (LSB) corresponds to x. |
|
|
|
|
+| | | |
|
|
|
|
+| | | For example, a bvec2 of (bx, by) could be created in |
|
|
|
|
+| | | the following way: |
|
|
|
|
+| | | |
|
|
|
|
+| | | .. code-block:: gdscript |
|
|
|
|
+| | | |
|
|
|
|
+| | | bvec2_input: int = (int(bx)) | (int(by) << 1) |
|
|
|
|
+| | | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **bvec3** | **int** | Bitwise packed int where bit 0 (LSB) corresponds to x. |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **bvec4** | **int** | Bitwise packed int where bit 0 (LSB) corresponds to x. |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **int** | **int** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **ivec2** | **Vector2i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **ivec3** | **Vector3i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **ivec4** | **Vector4i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **uint** | **int** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **uvec2** | **Vector2i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **uvec3** | **Vector3i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **uvec4** | **Vector4i** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **float** | **float** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **vec2** | **Vector2** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **vec3** | **Vector3**, **Color** | When Color is used, it will be interpreted as (r, g, b). |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **vec4** | **Vector4**, **Color**, | When Color is used, it will be interpreted as (r, g, b, a).|
|
|
|
|
+| | **Rect2**, **Plane**, | |
|
|
|
|
+| | **Quaternion** | When Rect2 is used, it will be interpreted as |
|
|
|
|
+| | | (position.x, position.y, size.x, size.y). |
|
|
|
|
+| | | |
|
|
|
|
+| | | When Plane is used it will be interpreted as |
|
|
|
|
+| | | (normal.x, normal.y, normal.z, d). |
|
|
|
|
+| | | |
|
|
|
|
+| | | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **mat2** | **Transform2D** | |
|
|
|
|
+| | | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **mat3** | **Basis** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **mat4** | **Projection**, | When a Transform3D is used, the w Vector is set to the |
|
|
|
|
+| **mat4** | **Transform3D** | identity. |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **sampler2D** | **Texture2D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **isampler2D** | **Texture2D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **usampler2D** | **Texture2D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **sampler2DArray** | **Texture2DArray** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **isampler2DArray** | **Texture2DArray** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **usampler2DArray** | **Texture2DArray** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **sampler3D** | **Texture3D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **isampler3D** | **Texture3D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **usampler3D** | **Texture3D** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **samplerCube** | **Cubemap** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+| **samplerCubeArray** | **CubemapArray** | |
|
|
|
|
++----------------------+-------------------------+------------------------------------------------------------+
|
|
|
|
+
|
|
.. note:: Be careful when setting shader uniforms from GDScript, no error will
|
|
.. note:: Be careful when setting shader uniforms from GDScript, no error will
|
|
be thrown if the type does not match. Your shader will just exhibit
|
|
be thrown if the type does not match. Your shader will just exhibit
|
|
undefined behavior.
|
|
undefined behavior.
|