ef_p3.effect 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. u_point: { value: [1,1] }
  15. u_start: {value: 0 }
  16. alphaThreshold: { value: 0.5 }
  17. outlineSize: { value: [0.1,0.01] }
  18. outlineColor: { value: [1,0,0,0.0] }
  19. }%
  20. CCProgram vs %{
  21. precision highp float;
  22. #include <cc-global>
  23. #include <cc-local>
  24. in vec3 a_position;
  25. in vec4 a_color;
  26. out vec4 v_color;
  27. #if USE_TEXTURE
  28. in vec2 a_uv0;
  29. out vec2 v_uv0;
  30. #endif
  31. uniform Constant{
  32. vec2 u_point;
  33. float u_start;
  34. };
  35. void main () {
  36. vec4 pos = vec4(a_position, 1);
  37. pos.x += (u_point.x - pos.x) * ((pos.y - u_start) / (pos.y - u_point.y));
  38. // 下面的代码基本都不敢动,我们只修改上面
  39. // 模型的顶点变换 不敢动!
  40. #if CC_USE_MODEL
  41. pos = cc_matViewProj * cc_matWorld * pos;
  42. #else
  43. pos = cc_matViewProj * pos;
  44. #endif
  45. // 给片元着色器传值 v_uv0 不敢动!
  46. #if USE_TEXTURE
  47. v_uv0 = a_uv0;
  48. #endif
  49. // 给片元着色器传值 v_color 不敢动! 这个v_color就是在sprite组件里能调整的颜色的值
  50. v_color = a_color;
  51. // 输出的最终坐标。
  52. gl_Position = pos;
  53. }
  54. }%
  55. CCProgram fs %{
  56. precision highp float;
  57. #include <alpha-test>
  58. #include <texture>
  59. in vec4 v_color;
  60. #if USE_TEXTURE
  61. in vec2 v_uv0;
  62. uniform sampler2D texture;
  63. #endif
  64. uniform line{
  65. vec4 outlineColor;
  66. vec2 outlineSize;
  67. };
  68. void main () {
  69. vec4 o = vec4(1, 1, 1, 1);
  70. #if USE_TEXTURE
  71. CCTexture(texture, v_uv0, o);
  72. #endif
  73. o *= v_color;
  74. ALPHA_TEST(o);
  75. gl_FragColor = o;
  76. }
  77. }%