Skip to content

Commit 5f96ee0

Browse files
committed
Clarify array and struct uniforms being supported in Shading language
1 parent 0e4add4 commit 5f96ee0

File tree

2 files changed

+121
-6
lines changed

2 files changed

+121
-6
lines changed

classes/class_node_2d.gd.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
:github_url: hide
2+
3+
.. DO NOT EDIT THIS FILE!!!
4+
.. Generated automatically from Godot engine sources.
5+
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
6+
.. XML source: https://github.com/godotengine/godot/tree/master/docs/node_2d.gd.xml.
7+
8+
.. _class_node_2d_gd:
9+
10+
"node_2d.gd"
11+
============
12+
13+
**Inherits:** ``Node2D``
14+
15+
.. container:: contribute
16+
17+
There is currently no description for this class. Please help us by `contributing one <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__!
18+
19+
.. rst-class:: classref-reftable-group
20+
21+
Properties
22+
----------
23+
24+
.. table::
25+
:widths: auto
26+
27+
+-------------+---------------------------------------------+-------+
28+
| ``Variant`` | :ref:`test<class_node_2d_gd_property_test>` | ``1`` |
29+
+-------------+---------------------------------------------+-------+
30+
31+
.. rst-class:: classref-reftable-group
32+
33+
Methods
34+
-------
35+
36+
.. table::
37+
:widths: auto
38+
39+
+--------+-------------------------------------------------------------+
40+
| |void| | :ref:`_ready<class_node_2d_gd_private_method__ready>`\ (\ ) |
41+
+--------+-------------------------------------------------------------+
42+
43+
.. rst-class:: classref-section-separator
44+
45+
----
46+
47+
.. rst-class:: classref-descriptions-group
48+
49+
Property Descriptions
50+
---------------------
51+
52+
.. _class_node_2d_gd_property_test:
53+
54+
.. rst-class:: classref-property
55+
56+
``Variant`` **test** = ``1`` :ref:`🔗<class_node_2d_gd_property_test>`
57+
58+
This is a test comment.
59+
60+
.. note::
61+
62+
This is a ``note``.
63+
64+
.. warning::
65+
66+
This is a ``warning``.
67+
68+
.. tip::
69+
70+
This is a ``tip``.
71+
72+
.. important::
73+
74+
This is ``important``.
75+
76+
77+
78+
More text following admonitions.
79+
80+
.. rst-class:: classref-section-separator
81+
82+
----
83+
84+
.. rst-class:: classref-descriptions-group
85+
86+
Method Descriptions
87+
-------------------
88+
89+
.. _class_node_2d_gd_private_method__ready:
90+
91+
.. rst-class:: classref-method
92+
93+
|void| **_ready**\ (\ ) :ref:`🔗<class_node_2d_gd_private_method__ready>`
94+
95+
.. container:: contribute
96+
97+
There is currently no description for this method. Please help us by `contributing one <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__!
98+
99+
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
100+
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
101+
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
102+
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
103+
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
104+
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
105+
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
106+
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
107+
.. |void| replace:: :abbr:`void (No return value.)`

tutorials/shaders/shader_reference/shading_language.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
255259
information. In many cases, mobile drivers cause inconsistent or unexpected
256260
behavior and it is best to avoid specifying precision unless necessary.
257261

262+
.. _doc_shading_language_arrays:
263+
258264
Arrays
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+
414422
Structs
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

Comments
 (0)