myEffect.effect 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }%
  16. CCProgram vs %{
  17. precision highp float;
  18. #include <cc-global>
  19. #include <cc-local>
  20. in vec3 a_position;
  21. in vec4 a_color;
  22. out vec4 v_color;
  23. #if USE_TEXTURE
  24. in vec2 a_uv0;
  25. out vec2 v_uv0;
  26. #endif
  27. void main () {
  28. vec4 pos = vec4(a_position, 1);
  29. #if CC_USE_MODEL
  30. pos = cc_matViewProj * cc_matWorld * pos;
  31. #else
  32. pos = cc_matViewProj * pos;
  33. #endif
  34. #if USE_TEXTURE
  35. v_uv0 = a_uv0;
  36. #endif
  37. v_color = a_color;
  38. gl_Position = pos;
  39. }
  40. }%
  41. CCProgram fs %{
  42. precision highp float;
  43. #include <alpha-test>
  44. #include <texture>
  45. in vec4 v_color;
  46. #if USE_TEXTURE
  47. in vec2 v_uv0;
  48. uniform sampler2D texture;
  49. #endif
  50. void main () {
  51. vec4 o = vec4(1, 1, 1, 1);
  52. #if USE_TEXTURE
  53. CCTexture(texture, v_uv0, o);
  54. #endif
  55. o *= v_color;
  56. ALPHA_TEST(o);
  57. gl_FragColor = o;
  58. }
  59. }%