Accessing a vertex color in a Surface Shader
Let's begin this chapter by taking a look at how we can access the information of a model's vertex using the vertex function in a Surface Shader. This will arm us with the knowledge to start utilizing the elements contained within a model's vertex to create really useful and visually appealing effects.
A vertex in a vertex function can return information about itself that we need to be aware of. You can actually retrieve the vertices' normal directions as a float3
value, the position of the vertex as float3
, and you can even store color values in each vertex and return that color as float4
. This is what we will take a look at in this recipe. We need to see how to store color information and retrieve this stored color information inside each vertex of a Surface Shader.
Getting ready
In order to write this shader, we need to prepare a few assets. The following steps will set us up to create this Vertex Shader:
- In order to view the...