Advertisement
netgrind

TintByDistance

Nov 11th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //By Cale Bradbury (@netgrind)
  2. //glsl shader for tinting based on distance the sample color is from the target color
  3.  
  4. uniform sampler2D tex0; //input texture
  5. varying vec2 tcoord;    //coordinate of sample
  6. uniform vec4 color; //color to show
  7. uniform float dist; //controls how close to the color is shown
  8.  
  9. void main() {
  10.     vec4 c = texture2D(tex0,tcoord);        //sample texture    
  11.     gl_FragColor = c*(1-distance(c,color)*dist);    //tint sample color based on distance it is from the target color
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement