Skip to content

Instantly share code, notes, and snippets.

@decitrig
Last active November 30, 2019 16:28
Show Gist options
  • Save decitrig/20a05714797aeff43aadc80e9f954bc9 to your computer and use it in GitHub Desktop.
Save decitrig/20a05714797aeff43aadc80e9f954bc9 to your computer and use it in GitHub Desktop.
Shaders for showing DirectX coordinate conventions
static const float4 kPositions[] = {
// A downard-pointing triangle near the viewer.
float4(-1, 1, 0, 1), // Red
float4(1, 1, 0, 1), // Green
float4(0, -1, 0, 1), // Blue
// An upward-pointing triangle far from the viewer.
float4(1, -1, .9, 1), // Red
float4(-1, -1, .9, 1), // Green
float4(0, 1, .9, 1), // Blue
};
static const float4 kColors[] = {
float4(1, 0, 0, 1),
float4(0, 1, 0, 1),
float4(0, 0, 1, 1),
};
ClipSpaceVertex main(uint index : SV_VertexId) {
ClipSpaceVertex v;
v.pos = kPositions[index % 6];
v.color = kColors[index % 3];
return v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment