Created
January 27, 2019 03:57
-
-
Save sgnm/5f0cf5201835254cda0d9d8f0f9a6752 to your computer and use it in GitHub Desktop.
Thermal effect on infrared camera image (not real)
This file contains hidden or 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
out vec4 fragColor; | |
uniform float saturation; | |
uniform float brightness; | |
uniform float phase; | |
const float MIN_HUE = 0.0; | |
const float MAX_HUE = 0.66; | |
const float PHASE = 0.25; | |
vec3 hsb2rgb( in vec3 c ) | |
{ | |
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0), | |
6.0)-3.0)-1.0, | |
0.0, | |
1.0 ); | |
rgb = rgb*rgb*(3.0-2.0*rgb); | |
return c.z * mix( vec3(1.0), rgb, c.y); | |
} | |
void main() | |
{ | |
vec4 color = texture(sTD2DInputs[0], vUV.st); | |
float src_color = color.r; | |
src_color *= MAX_HUE; | |
src_color += clamp(phase, 0.0, 1.0) * PHASE; | |
float h = clamp(MAX_HUE - src_color, MIN_HUE, MAX_HUE); | |
float s = clamp(saturation, 0.0, 1.0); | |
float v = clamp(brightness, 0.0, 1.0); | |
color.rgb = hsb2rgb(vec3(h, s, v)); | |
fragColor = TDOutputSwizzle(color); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment