builtin-2d-gray-sprite.effect 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  2. %{
  3. techniques: [
  4. {
  5. passes: [
  6. {
  7. vert: vs
  8. frag: fs
  9. cullMode: none
  10. blend: true
  11. }
  12. ]
  13. layer: 0
  14. }
  15. ]
  16. properties: {
  17. texture: {
  18. type: sampler2D
  19. value: null
  20. }
  21. }
  22. %}
  23. %% vs {
  24. precision highp float;
  25. uniform mat4 cc_matViewProj;
  26. attribute vec3 a_position;
  27. attribute mediump vec2 a_uv0;
  28. varying mediump vec2 v_uv0;
  29. void main () {
  30. gl_Position = cc_matViewProj * vec4(a_position, 1);
  31. v_uv0 = a_uv0;
  32. }
  33. }
  34. %% fs {
  35. precision highp float;
  36. uniform sampler2D texture;
  37. varying mediump vec2 v_uv0;
  38. void main () {
  39. vec4 color = texture2D(texture, v_uv0);
  40. #if _USE_ETC1_TEXTURE
  41. color.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
  42. #endif
  43. float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;
  44. gl_FragColor = vec4(gray, gray, gray, color.a);
  45. }
  46. }