Skip to content

Instantly share code, notes, and snippets.

@daniel-j
Created January 25, 2012 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-j/1676943 to your computer and use it in GitHub Desktop.
Save daniel-j/1676943 to your computer and use it in GitHub Desktop.
// VERTEX SHADER
attribute vec2 a_position;
uniform vec2 u_resolution;
uniform vec3 u_palette[256];
varying vec3 v_color;
void main() {
// convert the pixel positions to -1->+1 (clipspace)
vec2 clipSpace = ((a_position / u_resolution) * 2.0) - 1.0;
int index = int(a_position.x);
v_color = u_palette[index];
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment