uv.effect 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  2. CCEffect %{
  3. techniques:
  4. - passes:
  5. - vert: vs
  6. frag: fs
  7. blendState:
  8. targets:
  9. - blend: true
  10. rasterizerState:
  11. cullMode: none
  12. properties:
  13. texture: { value: white }
  14. time: { value: 0 }
  15. speed: { value: 0.002 }
  16. }%
  17. CCProgram vs %{
  18. precision highp float;
  19. #include <cc-global>
  20. in vec3 a_position;
  21. in mediump vec2 a_uv0;
  22. out mediump vec2 v_uv0;
  23. in vec4 a_color;
  24. out vec4 v_color;
  25. void main () {
  26. gl_Position = cc_matViewProj * vec4(a_position, 1);
  27. v_uv0 = a_uv0;
  28. v_color = a_color;
  29. }
  30. }%
  31. CCProgram fs %{
  32. precision highp float;
  33. uniform Time {
  34. float time;
  35. };
  36. uniform SPEED {
  37. float speed;
  38. };
  39. uniform sampler2D texture;
  40. in mediump vec2 v_uv0;
  41. in vec4 v_color;
  42. void main () {
  43. vec2 uv = v_uv0.xy;
  44. uv.y += time * speed;
  45. uv.y = fract(uv.y);
  46. vec4 color = texture2D(texture, uv);
  47. gl_FragColor = color;
  48. }
  49. }%