Skip to content

Instantly share code, notes, and snippets.

@SpineyPete
Last active October 27, 2017 01:02
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 SpineyPete/d07b869c831380369aed594fa3e99a5f to your computer and use it in GitHub Desktop.
Save SpineyPete/d07b869c831380369aed594fa3e99a5f to your computer and use it in GitHub Desktop.
Crosstalk
// Crosstalk makes HDR highlights tend towards white.
// This is more realistic and maintains definition in overexposed areas.
// --
// Threshold is the point at which the desaturation kicks in.
// Shallowness is the rate at which the color reaches pure white.
// Higher Shallowness values create a slower rise.
vec3 Crosstalk(vec3 color, float threshold, float shallowness) {
// Luminosity
float luma = color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
// Blending Factor (sigmoid curve)
float blend = max(luma - threshold, 0.0);
blend *= blend;
blend /= blend + shallowness;
// Mix RGB with grayscale luminosity to simulate crosstalk.
return mix(color, vec3(luma), blend);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment