// This file contains code to produce both the rainbow color scale and the heated-object color scale. // It returns an RGB color in a vec3. // Pass in a variable called "t" where t=0. will give you back the color at the bottom of the scale // and t=1. will give you back the color at the top of the scale. vec3 Rainbow( float t ) { t = clamp( t, 0., 1. ); vec3 rgb; // b -> c rgb.r = 0.; rgb.g = 4. * ( t - (0./4.) ); rgb.b = 1.; // c -> g if( t >= (1./4.) ) { rgb.r = 0.; rgb.g = 1.; rgb.b = 1. - 4. * ( t - (1./4.) ); } // g -> y if( t >= (2./4.) ) { rgb.r = 4. * ( t - (2./4.) ); rgb.g = 1.; rgb.b = 0.; } // y -> r if( t >= (3./4.) ) { rgb.r = 1.; rgb.g = 1. - 4. * ( t - (3./4.) ); rgb.b = 0.; } return rgb; } vec3 HeatedObject( float t ) { t = clamp( t, 0., 1. ); vec3 rgb; rgb.r = 3. * ( t - (0./6.) ); rgb.g = 0.; rgb.b = 0.; if( t >= (1./3.) ) { rgb.r = 1.; rgb.g = 3. * ( t - (1./3.) ); } if( t >= (2./3.) ) { rgb.g = 1.; rgb.b = 3. * ( t - (2./3.) ); } return rgb; }