mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
Add documentation for hint_enum uniform in shading_language.rst (#9841)
* Adding documentation for ``hint_enum`` uniform in shading_language.rst Added explanation regarding ``hint_enum`` behaviour and usage in Uniforms section. Also added a row in the Uniforms section table to reflect this new hint type This PR is documentation regarding : godotengine/godot#94324 --------- Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
This commit is contained in:
@@ -802,6 +802,24 @@ GDScript:
|
||||
|
||||
material.set_shader_parameter("colors", [Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(0, 0, 1)])
|
||||
|
||||
You can access ``int`` values as a readable dropdown widget using the ``hint_enum`` uniform:
|
||||
|
||||
.. code-block:: glsl
|
||||
|
||||
uniform int noise_type : hint_enum("OpenSimplex2", "Cellular", "Perlin", "Value") = 0;
|
||||
|
||||
.. note:: Unlike ``@export_enum`` in GDScript, the ``hint_enum`` uniform does not support
|
||||
the use of ``String``\ s, it only supports ``int``\ s.
|
||||
|
||||
You can assign explicit values to the ``hint_enum`` uniform using colon syntax similar to GDScript:
|
||||
|
||||
.. code-block:: glsl
|
||||
|
||||
uniform int character_speed: hint_enum("Slow:30", "Average:60", "Very Fast:200") = 60;
|
||||
|
||||
The value will be stored as an integer, corresponding to the index of the selected option (i.e. 0, 1, or 2)
|
||||
or the value assigned by colon syntax (i.e. 30, 60, or 200).
|
||||
|
||||
.. note:: The first argument to ``set_shader_parameter`` is the name of the uniform
|
||||
in the shader. It must match *exactly* to the name of the uniform in
|
||||
the shader or else it will not be recognized.
|
||||
@@ -860,6 +878,8 @@ Full list of uniform hints below:
|
||||
+======================+==================================================+=============================================================================+
|
||||
| **vec3, vec4** | source_color | Used as color. |
|
||||
+----------------------+--------------------------------------------------+-----------------------------------------------------------------------------+
|
||||
| **int** | hint_enum("String1", "String2") | Displays int input as a dropdown widget in the editor. |
|
||||
+----------------------+--------------------------------------------------+-----------------------------------------------------------------------------+
|
||||
| **int, float** | hint_range(min, max[, step]) | Restricted to values in a range (with min/max/step). |
|
||||
+----------------------+--------------------------------------------------+-----------------------------------------------------------------------------+
|
||||
| **sampler2D** | source_color | Used as albedo color. |
|
||||
|
||||
Reference in New Issue
Block a user