attacked.effect 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // 攻击效果
  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. addColor: { value: [0.8, 0.8, 0.8, 0.8] }
  16. }%
  17. CCProgram vs %{
  18. precision highp float;
  19. #include <cc-global>
  20. #include <cc-local>
  21. in vec3 a_position;
  22. in vec4 a_color;
  23. out vec4 v_color;
  24. #if USE_TEXTURE
  25. in vec2 a_uv0;
  26. out vec2 v_uv0;
  27. #endif
  28. void main () {
  29. vec4 pos = vec4(a_position, 1);
  30. #if CC_USE_MODEL
  31. pos = cc_matViewProj * cc_matWorld * pos;
  32. #else
  33. pos = cc_matViewProj * pos;
  34. #endif
  35. #if USE_TEXTURE
  36. v_uv0 = a_uv0;
  37. #endif
  38. v_color = a_color;
  39. gl_Position = pos;
  40. }
  41. }%
  42. CCProgram fs %{
  43. precision highp float;
  44. #include <alpha-test>
  45. #include <texture>
  46. in vec4 v_color;
  47. #if USE_TEXTURE
  48. in vec2 v_uv0;
  49. uniform sampler2D texture;
  50. #endif
  51. #if USE_TINT
  52. in vec4 v_dark;
  53. #endif
  54. uniform param{
  55. vec4 addColor;
  56. };
  57. void main () {
  58. vec4 o = vec4(1, 1, 1, 1);
  59. #if USE_TEXTURE
  60. o *= texture(texture, v_uv0);
  61. #if CC_USE_ALPHA_ATLAS_TEXTURE
  62. o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
  63. #endif
  64. #endif
  65. o *= v_color;
  66. ALPHA_TEST(o);
  67. o.rgb = o.rgb + addColor.rgb;
  68. gl_FragColor = o;
  69. }
  70. }%