Skip to content

Instantly share code, notes, and snippets.

@lewkoo
Created February 27, 2014 03:20
Show Gist options
  • Select an option

  • Save lewkoo/9243762 to your computer and use it in GitHub Desktop.

Select an option

Save lewkoo/9243762 to your computer and use it in GitHub Desktop.
Fragment shader for a very simple Android shader example
precision highp float;
void main()
{
// gl_FragCoord contains the window relative coordinate for the fragment.
// we use gl_FragCoord.x position to control the red color value.
// we use gl_FragCoord.y position to control the green color value.
// please note that all r, g, b, a values are between 0 and 1.
float windowWidth = 1024.0;
float windowHeight = 768.0;
float r = gl_FragCoord.x / windowWidth;
float g = gl_FragCoord.y / windowHeight;
float b = 1.0;
float a = 1.0;
gl_FragColor = vec4(r, g, b, a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment