Exploring Uniform Arrays in the Godot 4 shader language
In this recipe, we create a shader on a MeshInstance3D that uses the new Uniform Array, which is a Vector3
array and holds three colors—red, green, and blue—in the array.
Getting ready
For this recipe, open Godot 4 and open the project from the last recipe, called CreationDialog
.
How to do it…
Let’s use the new Uniform Arrays and structs in the shader language with the plane we created in the last recipe:
- Left-click on MeshInstance3D in the Scene tab.
- Click on <empty> to the right of Material in the Inspector and select New ShaderMaterial from the drop-down list.
- Click on <empty> to the right of Shader in the Inspector and select New Shader from the drop-down list, as shown in Figure 5.1.
- To the right of Path:, rename
CreationDialog.gdshader
toRecipe2.gdshader
and click the Create button. - Left-click on Recipe2.gdshader, which is to the right of Shader...