Using Instance Uniforms with shaders
In this recipe, we will create two instance uniform variables—color
and alphachannel
—in a shader script. We see that the variables that we created can now be seen in Inspector and changed from there, not from the script.
Getting ready
For this recipe, click the + sign to the right of the CreationDialog scene we just completed to add a new scene. In the Scene tab, click 3D Scene. Click on Scene in the top-left corner next to Project, then select Save Scene As, and name it InstanceUniforms
.
How to do it…
Let’s add MeshInstance3D with a PlaneMesh and then write a shader script with the two Instance Uniforms:
- Left-click on the Node3D node and then press the + sign in the Scene tab. In the Create New Node window, type
mesh
in the Search box and then select MeshInstance3D to create the node in the scene. - In the Inspector, click on <empty> to the right of Mesh and select New PlaneMesh.
- Left...