@@ -91,6 +91,10 @@ Most GLSL ES 3.0 datatypes are supported:
9191| | Only supported in Compatibility/Android platform. |
9292+------------------------+---------------------------------------------------------------------------------+
9393
94+ These types can also be put inside :ref: `arrays <doc_shading_language_arrays >`
95+ or :ref: `structs <doc_shading_language_structs >`, which are also usable as uniforms,
96+ function parameters, or return values.
97+
9498.. warning ::
9599
96100 Local variables are not initialized to a default value such as ``0.0 ``. If
@@ -255,6 +259,8 @@ precisions. Refer to the documentation of the target architecture for further
255259information. In many cases, mobile drivers cause inconsistent or unexpected
256260behavior and it is best to avoid specifying precision unless necessary.
257261
262+ .. _doc_shading_language_arrays :
263+
258264Arrays
259265------
260266
@@ -411,6 +417,8 @@ Alternatively, this can be done by using the ``uint(x)`` built-in conversion fun
411417 uint a = 1u;
412418 uint b = uint(1);
413419
420+ .. _doc_shading_language_structs :
421+
414422Structs
415423-------
416424
@@ -1104,23 +1112,23 @@ method on a node that inherits from :ref:`class_GeometryInstance3D`:
11041112
11051113 When using per-instance uniforms, there are some restrictions you should be aware of:
11061114
1107- - **Per-instance uniforms do not support textures or arrays **, only regular scalar and vector types.
1115+ - **Per-instance uniforms do not support textures or arrays **, only regular scalar and vector types.
11081116
11091117.. note ::
11101118
11111119 Due to GLSL limitations, you cannot directly index a texture array
11121120 using a per-instance uniform. Sampler arrays can only be indexed by
11131121 compile-time constant expressions.
1114-
1122+
11151123 As a workaround, pass a texture array as a regular uniform and the
11161124 desired texture index as a per-instance uniform. Then use a ``switch ``
11171125 statement to select the texture:
1118-
1126+
11191127 .. code-block :: glsl
1120-
1128+
11211129 uniform sampler2D texture_array[4];
11221130 instance uniform int texture_index;
1123-
1131+
11241132 void fragment() {
11251133 vec4 color;
11261134 switch (texture_index) {
@@ -1137,7 +1145,7 @@ When using per-instance uniforms, there are some restrictions you should be awar
11371145 color = texture(texture_array[3], UV);
11381146 break;
11391147 }
1140-
1148+
11411149 COLOR = color;
11421150 }
11431151
0 commit comments