Guest User

Untitled

a guest
Nov 20th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #ifdef GL_ES
  2. precision mediump float;
  3. precision mediump int;
  4. #endif
  5.  
  6. uniform sampler2D texture;
  7. varying vec4 vertTexCoord;
  8.  
  9. struct ColorStop {
  10. float percent;
  11. vec4 color;
  12. };
  13.  
  14. ColorStop[] gradient = ColorStop[4] (
  15. ColorStop(0.0, vec4(0.5, 1.0, 0.0, 1.0)),
  16. ColorStop(0.25, vec4(1.0, 0.5, 0.0, 1.0)),
  17. ColorStop(0.5, vec4(1.0, 1.0, 0.0, 1.0)),
  18. ColorStop(1.0, vec4(0.0, 0.0, 1.0, 1.0))
  19. );
  20.  
  21. vec4 eval(ColorStop[4] grd, float t) {
  22. /* Logic from Java Gradient class translated,
  23. with preferred easing function and color mode. */
  24. }
  25.  
  26. void main(void) {
  27. vec4 pxl = texture2D(texture, vertTexCoord.xy);
  28. float bri = (pxl.x + pxl.y + pxl.z) / 3.0;
  29. gl_FragColor = eval(gradient, bri);
  30. }
Add Comment
Please, Sign In to add comment