Skip to content

Instantly share code, notes, and snippets.

@companje
Last active February 9, 2021 08:13
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 companje/60a671fcb08e5e1591ad3afb673cd8a9 to your computer and use it in GitHub Desktop.
Save companje/60a671fcb08e5e1591ad3afb673cd8a9 to your computer and use it in GitHub Desktop.
Chromatic Aberration with blueScaler and yellowDecrease
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
varying vec4 vertTexCoord;
//downscale the blue channel to correct
//for chromatic aberration of fish eye lens
const float blueScaler = 1 - (1 / 600.);
void main() {
//also decrease the amount of yellow towards outside
const float yellowDecrease = .3 * length(vertTexCoord.st-.5);
gl_FragColor.rg = texture2D(texture, vertTexCoord.st).rg - yellowDecrease;
gl_FragColor.b = texture2D(texture, ((vertTexCoord.st-.5)*blueScaler)+.5).b;
}
@companje
Copy link
Author

companje commented Feb 9, 2021

66738010-fa954800-ee5c-11e9-8437-ec1c296a9b82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment