In this chapter, we will give the triangle some color, with a technique called “Vertex Colors”.
This used to be very popular back in the day, before using textures was as cheap as it is now.
Many engines and frameworks still have the functionality,
but nowadays graphics programmers usually use it to transfer other data than actual colors.
Still, it is a good place to start, as it teaches how to transfer more arbitrary data to the GPU with each vertex.
struct float3
{
float x, y, z;
};
struct Vertex
{
float3 position;
};
struct Input
{
float3 Position : TEXCOORD0;
};
struct Output
{
float4 Position : SV_Position;
};
Output main(Input input)
{
Output output;
output.Position = float4(input.Position, 1.0f);
return output;
}
← Previous Chapter | Index | Next Chapter → |