/shaders/fragment/tile-explosion.fs

https://github.com/ajanthanm/cssfilterlab · F# · 37 lines · 27 code · 6 blank · 4 comment · 2 complexity · d4ba54882490a9129de809ed43f3955e MD5 · raw file

  1. /*
  2. * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. precision mediump float;
  17. // Uniforms passed in in from CSS
  18. uniform float t;
  19. uniform float fade;
  20. // Main
  21. void main()
  22. {
  23. // As t increases from [0 -> 0.5 -> 1],
  24. // fadeFactor increases and then decreases from [0 -> 1 -> 0].
  25. float fadeFactor = 2.0 * t;
  26. if (fadeFactor > 1.0)
  27. fadeFactor = 2.0 - fadeFactor;
  28. float currentFade = 1.0 - fadeFactor * fade;
  29. css_ColorMatrix = mat4(1.0);
  30. css_ColorMatrix[3][3] = currentFade;
  31. }