-
-
Save Volcanoscar/b8701cbba4df378e56a1dafc790387e1 to your computer and use it in GitHub Desktop.
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
#define PROCESSING_TEXTURE_SHADER | |
uniform sampler2D texture; | |
uniform vec2 texOffset; | |
varying vec4 vertColor; | |
varying vec4 vertTexCoord; | |
uniform float level; | |
float map(float a,float amin,float amax,float bmin,float bmax) { | |
return (a-amin)/(amax-amin) * (bmax-bmin) + bmin; | |
} | |
void main(void) { | |
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t); | |
vec4 col0 = texture2D(texture, tc0); | |
vec4 color; | |
vec4 dark_blue = vec4(0.0,0.0,0.5,1.0); | |
vec4 light_blue = vec4(0.,0.658,1.0,1.0); | |
vec4 dark_green = vec4(0.0,0.5,0.0,1.0); | |
vec4 light_green = vec4(0.0,1.0,0.0,1.0); | |
vec4 black = vec4(0.0,0.0,0.0,1.0); | |
if (col0.r<level) { | |
color = mix(dark_blue,light_blue,col0.r/level); | |
} | |
else { | |
float p = map(col0.r,level,1.0,0.0,1.0); | |
color = mix(dark_green,black,p); | |
} | |
gl_FragColor = color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment