Skip to content

Instantly share code, notes, and snippets.

@TheoBendixson
Last active June 14, 2021 22:02
Show Gist options
  • Save TheoBendixson/6c4000290880b35c46d8245cb3bee30b to your computer and use it in GitHub Desktop.
Save TheoBendixson/6c4000290880b35c46d8245cb3bee30b to your computer and use it in GitHub Desktop.
2D Pixel Art Rasterizer Data Struct (Metal Shading Language)
typedef struct
{
// Rasterizer position output data, in terms of Apple's normalized device
// coordinates. The vertex shader maps on screen pixel coordinates to normalized
// device coordinates and stores the output in this value.
float4 position [[position]];
// The fragment texture coordinate, expressed in standard UV notation where 0.0f
// is the beginning and 1.0f is the end of a textured quad.
float2 textureCoordinate;
// The scaled texture coordinate, a mapping from the texture coordinate, making
// it easier to reason about the location of individual texels. This is basically
// textureCoordinate*textureSize.
float2 vUv;
// The size of the source texture in pixels.
float2 textureSize;
} RasterizerData;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment