How to use Global Uniforms
In this recipe, we go into Project Settings and create a Shader Global Uniform that is a red color. We create a PlaneMesh and call the Shader Global Uniform from a shader script to change the plane color to red, then we create a script and change the color to blue using GDScript.
Getting ready
For this recipe, open Godot 4 and open the project from the last recipe, called CreationDialog
.
How to do it…
We start by removing the Recipe2.gdshader
script from MeshInstance3D and then create the global shader:
- Left-click on MeshInstance3D, and in the Inspector in the Material section, click on the Set to default icon to the right of Shader and to the left of Recipe2.gdshader, as seen in Figure 5.3 just below the blue ball.
- Click on Output on the bottom panel of the editor to the right of the FileSystem tab.
- Click on Project in the main menu located on the top left of the editor.
- Select Project Settings in the drop-down list...