Last active
October 27, 2017 01:02
-
-
Save SpineyPete/d07b869c831380369aed594fa3e99a5f to your computer and use it in GitHub Desktop.
Crosstalk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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