kuang.effect 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. alphaThreshold: { value: 0.5 }
  15. width: {value: 0.05 }
  16. height: {value: 0.05 }
  17. }%
  18. CCProgram vs %{
  19. precision highp float;
  20. #include <cc-global>
  21. #include <cc-local>
  22. in vec3 a_position;
  23. in vec4 a_color;
  24. out vec4 v_color;
  25. #if USE_TEXTURE
  26. in vec2 a_uv0;
  27. out vec2 v_uv0;
  28. #endif
  29. void main () {
  30. vec4 pos = vec4(a_position, 1);
  31. #if CC_USE_MODEL
  32. pos = cc_matViewProj * cc_matWorld * pos;
  33. #else
  34. pos = cc_matViewProj * pos;
  35. #endif
  36. #if USE_TEXTURE
  37. v_uv0 = a_uv0;
  38. #endif
  39. v_color = a_color;
  40. gl_Position = pos;
  41. }
  42. }%
  43. CCProgram fs %{
  44. precision highp float;
  45. #include <alpha-test>
  46. #include <texture>
  47. in vec4 v_color;
  48. #if USE_TEXTURE
  49. in vec2 v_uv0;
  50. uniform sampler2D texture;
  51. #endif
  52. uniform Props{
  53. float width;
  54. float height;
  55. };
  56. void main () {
  57. vec4 o = vec4(1, 1, 1, 1);
  58. #if USE_TEXTURE
  59. CCTexture(texture, v_uv0, o);
  60. #endif
  61. if(v_uv0.x > width && v_uv0.x < 1.0 - width){
  62. if(v_uv0.y > height && v_uv0.y < 1.0 - height){
  63. o.a = 0.0;
  64. }
  65. }
  66. o *= v_color;
  67. ALPHA_TEST(o);
  68. gl_FragColor = o;
  69. }
  70. }%