Animating vertices in a Surface Shader
Now that we know how to access data on a per-vertex basis, let's expand our knowledge set to include other types of data and position of a vertex.
Using a vertex function, we can access the position of each vertex in a mesh. This allows us to actually modify each individual vertex while the shader does the processing.
In this recipe, we will create a shader that will allow us to modify the positions of each vertex on a mesh with a sine wave. This technique can be used to create animations for objects such as flags or waves on an ocean.
Getting ready
Let's gather our assets together so that we can create the code for our Vertex Shader:
Create a new scene and place a plane mesh in the center of the scene.
Then create a new shader and material.
Finally, assign the shader to the material and the material to the plane mesh.
Your scene should look similar to the following screenshot:
How to do it…
With our scene ready to go, let's double-click on our newly created...