1. Make some gradient (here we will use blue-yellow-red gradient).
2. Make thermal map texture (here we will substitute pixel luminance value for temperature)
3. Get pixel's temperature from thermal map texture and map it to gradient value.
GLSL code
#version 120
uniform sampler2D tex;
void main()
{
vec4 pixcol = texture2D(tex, gl_TexCoord[0].xy);
vec4 colors[3];
colors[0] = vec4(0.,0.,1.,1.);
colors[1] = vec4(1.,1.,0.,1.);
colors[2] = vec4(1.,0.,0.,1.);
float lum = (pixcol.r+pixcol.g+pixcol.b)/3.;
int ix = (lum < 0.5)? 0:1;
vec4 thermal = mix(colors[ix],colors[ix+1],(lum-float(ix)*0.5)/0.5);
gl_FragColor = thermal;
}
Tank
and after thermal vision shader applied:
Very good code.
ReplyDeleteWould it be difficult to make a convert of this code to Adobe Pixel Bender?
Thank you