top of page
Vertex Displacement
It is possible to control the positions of a mesh's vertices via a shader. This method is called Vertex Displacement. The CPU maintains the original positions of the mesh's vertices, but when it passes those values to the GPU, those vertex positions are hijacked and displaced.
This method can be useful for many different effects: Water, Distorting Surfaces, Terrain Manipulation, Explosions, Fragmentation and many more.
Hijacking Vertices
To displace a Vertex, you must change that vertex's position in the Vertex Program of your Shader. In Unity, that position is passed into your Vertex Program as POSITION. It is very simple to edit the vertices of a mesh's position via the Vertex Program:
This is a very simple approach to Vertex Displacement. Let's try something more advanced.
Driving Vertices Via Texture Displacement
By using the masking technique described in the Up-Vector Masking Shader tutorial, it is quite simple to drive displacement via a Texture Map. In this example, I introduce a Texture into the Vertex Program using:
For more information on tex2Dlod please see this page.
Using this method, we can displace vertices by the color values of the texture. It is a very simple approach, but can be powerful all the same. Below we use the method to create a lava surface, driving not only the vertices but the color of the surface itself.
bottom of page