Skip to content

Instantly share code, notes, and snippets.

@Macorreag
Created October 5, 2020 03:45
Show Gist options
  • Save Macorreag/9368c56b64292bc346fb511d061e9382 to your computer and use it in GitHub Desktop.
Save Macorreag/9368c56b64292bc346fb511d061e9382 to your computer and use it in GitHub Desktop.
// Pattern 1: Data sent from the sketch to the shaders
uniform sampler2D texture;
// Patter 2: Passing data among shaders
varying vec4 vertColor;
varying vec4 vertTexCoord;
const vec4 lumcoeff = vec4(0.299, 0.587, 0.114, 0);
void main() {
// Pattern 3: Consistency of space transformations
vec4 col = texture2D(texture, vertTexCoord.st);
float lum = dot(col, lumcoeff);
gl_FragColor = vec4(lum, lum, lum, 1.0) * vertColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment