f18742d7-56d2-4eb5-ae49-2d9d710b37c8.json 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. {
  2. "__type__": "cc.EffectAsset",
  3. "_name": "builtin-2d-label",
  4. "_objFlags": 0,
  5. "_native": "",
  6. "properties": null,
  7. "techniques": [
  8. {
  9. "passes": [
  10. {
  11. "blendState": {
  12. "targets": [
  13. {
  14. "blend": true
  15. }
  16. ]
  17. },
  18. "rasterizerState": {
  19. "cullMode": 0
  20. },
  21. "properties": {
  22. "texture": {
  23. "value": "white",
  24. "type": 29
  25. },
  26. "alphaThreshold": {
  27. "value": [
  28. 0.5
  29. ],
  30. "type": 13
  31. },
  32. "outlineSize": {
  33. "value": [
  34. 0
  35. ],
  36. "type": 13
  37. },
  38. "outlineColor": {
  39. "value": [
  40. 1,
  41. 1,
  42. 1,
  43. 1
  44. ],
  45. "type": 16
  46. }
  47. },
  48. "program": "builtin-2d-label|vs|fs"
  49. }
  50. ]
  51. }
  52. ],
  53. "shaders": [
  54. {
  55. "hash": 1105459032,
  56. "glsl3": {
  57. "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
  58. "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform Outline {\n vec4 outlineColor;\n float outlineSize;\n};\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture(texture, v_uv0).a;\n #else\n float dist = texture(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture(texture, v_uv0).a;\n #else\n o *= texture(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}"
  59. },
  60. "glsl1": {
  61. "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
  62. "frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if USE_SDF\nuniform vec4 outlineColor;\nuniform float outlineSize;\n#endif\nvoid main () {\n#if USE_SDF\n #if USE_TEXTURE_ALPHAONLY\n float dist = texture2D(texture, v_uv0).a;\n #else\n float dist = texture2D(texture, v_uv0).r;\n #endif\n #if USE_SDF_EXTEND\n const float EDGE_VALUE = 0.45;\n #else\n const float EDGE_VALUE = 0.5;\n #endif\n #if CC_SUPPORT_standard_derivatives\n float smoothing = fwidth(dist);\n #else\n float smoothing = 0.05;\n #endif\n float outEdge = EDGE_VALUE - outlineSize;\n float bg = smoothstep(outEdge - smoothing, outEdge, dist);\n float fg = smoothstep(EDGE_VALUE - smoothing, EDGE_VALUE, dist);\n vec4 fgColor = outlineColor * (1.0 - fg) + v_color * fg;\n gl_FragColor = vec4(fgColor.rgb, fgColor.a * bg);\n#else\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_TEXTURE_ALPHAONLY\n o.a *= texture2D(texture, v_uv0).a;\n #else\n o *= texture2D(texture, v_uv0);\n #endif\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n#endif\n}"
  63. },
  64. "builtins": {
  65. "globals": {
  66. "blocks": [
  67. {
  68. "name": "CCGlobal",
  69. "defines": []
  70. }
  71. ],
  72. "samplers": []
  73. },
  74. "locals": {
  75. "blocks": [
  76. {
  77. "name": "CCLocal",
  78. "defines": []
  79. }
  80. ],
  81. "samplers": []
  82. }
  83. },
  84. "defines": [
  85. {
  86. "name": "USE_TEXTURE",
  87. "type": "boolean",
  88. "defines": []
  89. },
  90. {
  91. "name": "CC_USE_MODEL",
  92. "type": "boolean",
  93. "defines": []
  94. },
  95. {
  96. "name": "CC_SUPPORT_standard_derivatives",
  97. "type": "boolean",
  98. "defines": []
  99. },
  100. {
  101. "name": "USE_ALPHA_TEST",
  102. "type": "boolean",
  103. "defines": []
  104. },
  105. {
  106. "name": "USE_SDF",
  107. "type": "boolean",
  108. "defines": []
  109. },
  110. {
  111. "name": "USE_TEXTURE_ALPHAONLY",
  112. "type": "boolean",
  113. "defines": [
  114. "USE_SDF"
  115. ]
  116. },
  117. {
  118. "name": "USE_SDF_EXTEND",
  119. "type": "boolean",
  120. "defines": [
  121. "USE_SDF"
  122. ]
  123. },
  124. {
  125. "name": "CC_USE_ALPHA_ATLAS_TEXTURE",
  126. "type": "boolean",
  127. "defines": [
  128. "USE_TEXTURE"
  129. ]
  130. }
  131. ],
  132. "blocks": [
  133. {
  134. "name": "ALPHA_TEST",
  135. "members": [
  136. {
  137. "name": "alphaThreshold",
  138. "type": 13,
  139. "count": 1
  140. }
  141. ],
  142. "defines": [
  143. "USE_ALPHA_TEST"
  144. ],
  145. "binding": 0
  146. },
  147. {
  148. "name": "Outline",
  149. "members": [
  150. {
  151. "name": "outlineColor",
  152. "type": 16,
  153. "count": 1
  154. },
  155. {
  156. "name": "outlineSize",
  157. "type": 13,
  158. "count": 1
  159. }
  160. ],
  161. "defines": [
  162. "USE_SDF"
  163. ],
  164. "binding": 1
  165. }
  166. ],
  167. "samplers": [
  168. {
  169. "name": "texture",
  170. "type": 29,
  171. "count": 1,
  172. "defines": [
  173. "USE_TEXTURE"
  174. ],
  175. "binding": 30
  176. }
  177. ],
  178. "record": null,
  179. "name": "builtin-2d-label|vs|fs"
  180. }
  181. ]
  182. }