Browse Source

Merge pull request #3087 from Chaosus/varying_array_note

Added note about varying arrays to shading_language
Rémi Verschelde 5 years ago
parent
commit
832192ca92
1 changed files with 17 additions and 1 deletions
  1. 17 1
      tutorials/shading/shading_reference/shading_language.rst

+ 17 - 1
tutorials/shading/shading_reference/shading_language.rst

@@ -191,7 +191,7 @@ Arrays
 ------
 
 Arrays are containers for multiple variables of a similar type.
-Note: As of Godot 3.2, only local arrays have been implemented.
+Note: As of Godot 3.2, only local and varying arrays have been implemented.
 
 Local arrays
 ~~~~~~~~~~~~
@@ -425,6 +425,22 @@ pixel in the fragment processor.
         ALBEDO = some_color;
     }
 
+Varying can also be an array:
+
+.. code-block:: glsl
+
+    shader_type spatial;
+
+    varying float var_arr[3];
+    void vertex() {
+        var_arr[0] = 1.0;
+        var_arr[1] = 0.0;
+    }
+
+    void fragment() {
+        ALBEDO = vec3(var_arr[0], var_arr[1], var_arr[2]); // red color
+    }
+
 Interpolation qualifiers
 ~~~~~~~~~~~~~~~~~~~~~~~~