e2f00085-c597-422d-9759-52c360279106.json 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. {
  2. "__type__": "cc.EffectAsset",
  3. "_name": "builtin-toon",
  4. "_objFlags": 0,
  5. "_native": "",
  6. "properties": null,
  7. "techniques": [
  8. {
  9. "passes": [
  10. {
  11. "name": "outline",
  12. "rasterizerState": {
  13. "cullMode": 1028
  14. },
  15. "depthStencilState": {
  16. "depthTest": true,
  17. "depthWrite": true
  18. },
  19. "properties": {
  20. "lineWidth": {
  21. "value": [
  22. 10
  23. ],
  24. "type": 13
  25. },
  26. "depthBias": {
  27. "value": [
  28. 0
  29. ],
  30. "type": 13
  31. },
  32. "outlineBaseColor": {
  33. "value": [
  34. 0,
  35. 0,
  36. 0,
  37. 1
  38. ],
  39. "editor": {
  40. "type": "color"
  41. },
  42. "type": 16
  43. },
  44. "outlineBaseColorMap": {
  45. "value": "gray",
  46. "type": 29
  47. }
  48. },
  49. "program": "builtin-toon|outline-vs:vert|outline-fs:frag"
  50. },
  51. {
  52. "name": "toon",
  53. "depthStencilState": {
  54. "depthTest": true,
  55. "depthWrite": true
  56. },
  57. "properties": {
  58. "tilingOffset": {
  59. "value": [
  60. 1,
  61. 1,
  62. 0,
  63. 0
  64. ],
  65. "type": 16
  66. },
  67. "normalMap": {
  68. "value": "normal",
  69. "type": 29
  70. },
  71. "baseColorMap": {
  72. "value": "white",
  73. "type": 29
  74. },
  75. "specular": {
  76. "value": [
  77. 1,
  78. 1,
  79. 1,
  80. 0.5
  81. ],
  82. "editor": {
  83. "type": "color"
  84. },
  85. "type": 16
  86. },
  87. "specularMap": {
  88. "value": "white",
  89. "type": 29
  90. },
  91. "specularThreshold": {
  92. "value": [
  93. 0.5
  94. ],
  95. "type": 13
  96. },
  97. "emissive": {
  98. "value": [
  99. 0,
  100. 0,
  101. 0,
  102. 1
  103. ],
  104. "editor": {
  105. "type": "color"
  106. },
  107. "type": 16
  108. },
  109. "emissiveMap": {
  110. "value": "white",
  111. "type": 29
  112. },
  113. "shadowColor": {
  114. "value": [
  115. 0,
  116. 0,
  117. 0,
  118. 1
  119. ],
  120. "editor": {
  121. "type": "color"
  122. },
  123. "type": 16
  124. },
  125. "shadowIntensity": {
  126. "value": [
  127. 0.5
  128. ],
  129. "type": 13
  130. },
  131. "highlightColor": {
  132. "value": [
  133. 1,
  134. 1,
  135. 1,
  136. 1
  137. ],
  138. "editor": {
  139. "type": "color"
  140. },
  141. "type": 16
  142. },
  143. "lightThreshold": {
  144. "value": [
  145. 0.5
  146. ],
  147. "type": 13
  148. },
  149. "lightSmoothness": {
  150. "value": [
  151. 0.1
  152. ],
  153. "type": 13
  154. }
  155. },
  156. "program": "builtin-toon|toon-vs:vert|toon-fs:frag"
  157. }
  158. ]
  159. }
  160. ],
  161. "shaders": [
  162. {
  163. "hash": 2752667346,
  164. "glsl3": {
  165. "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};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nout vec2 v_uv;\nuniform OutlineVert {\n float lineWidth;\n float depthBias;\n};\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n float width = lineWidth * 0.001;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(In.position.xyz);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n In.position.xyz += flip * dir * width * 2.0;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #else\n In.position.xyz += normalize(In.normal) * width;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #endif\n pos.z -= depthBias * 0.002;\n v_uv = In.uv;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",
  166. "frag": "\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};\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\n#if CC_NUM_LIGHTS > 0\nuniform CCLIGHTS {\n vec4 cc_lightPositionAndRange[4];\n vec4 cc_lightDirection[4];\n vec4 cc_lightColor[4];\n};\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nin vec2 v_uv;\nuniform OutlineFrag {\n vec4 outlineBaseColor;\n};\n#if USE_OUTLINE_BASE_COLOR_MAP\n uniform sampler2D outlineBaseColorMap;\n#endif\nvec4 frag () {\n vec4 color = outlineBaseColor;\n #if CC_NUM_DIR_LIGHTS > 0\n for (int i = 0; i < CC_NUM_DIR_LIGHTS; i++) {\n color *= cc_dirLightColor[i];\n }\n #endif\n #if USE_OUTLINE_BASE_COLOR_MAP\n vec4 outlineBaseColorMap_tmp = texture(outlineBaseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_outlineBaseColorMap\n outlineBaseColorMap_tmp.a *= texture(outlineBaseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (outlineBaseColorMap_tmp.rgb * outlineBaseColorMap_tmp.rgb);\n color.a *= outlineBaseColorMap_tmp.a;\n #else\n color *= outlineBaseColorMap_tmp;\n #endif\n #endif\n return vec4(color.rgb, 1.0);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"
  167. },
  168. "glsl1": {
  169. "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nvarying vec2 v_uv;\nuniform float lineWidth;\nuniform float depthBias;\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n float width = lineWidth * 0.001;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(In.position.xyz);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n In.position.xyz += flip * dir * width * 2.0;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #else\n In.position.xyz += normalize(In.normal) * width;\n vec4 pos = cc_matViewProj * cc_matWorld * In.position;\n #endif\n pos.z -= depthBias * 0.002;\n v_uv = In.uv;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",
  170. "frag": "\nprecision highp float;\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\n#if CC_NUM_LIGHTS > 0\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nvarying vec2 v_uv;\nuniform vec4 outlineBaseColor;\n#if USE_OUTLINE_BASE_COLOR_MAP\n uniform sampler2D outlineBaseColorMap;\n#endif\nvec4 frag () {\n vec4 color = outlineBaseColor;\n #if CC_NUM_DIR_LIGHTS > 0\n for (int i = 0; i < CC_NUM_DIR_LIGHTS; i++) {\n color *= cc_dirLightColor[i];\n }\n #endif\n #if USE_OUTLINE_BASE_COLOR_MAP\n vec4 outlineBaseColorMap_tmp = texture2D(outlineBaseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_outlineBaseColorMap\n outlineBaseColorMap_tmp.a *= texture2D(outlineBaseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (outlineBaseColorMap_tmp.rgb * outlineBaseColorMap_tmp.rgb);\n color.a *= outlineBaseColorMap_tmp.a;\n #else\n color *= outlineBaseColorMap_tmp;\n #endif\n #endif\n return vec4(color.rgb, 1.0);\n}\nvoid main() { gl_FragColor = frag(); }"
  171. },
  172. "builtins": {
  173. "globals": {
  174. "blocks": [
  175. {
  176. "name": "CCGlobal",
  177. "defines": []
  178. },
  179. {
  180. "name": "CC_SHADOW",
  181. "defines": [
  182. "CC_USE_SHADOW_MAP",
  183. "CC_NUM_SHADOW_LIGHTS"
  184. ]
  185. },
  186. {
  187. "name": "CCLIGHTS",
  188. "defines": [
  189. "CC_NUM_LIGHTS"
  190. ]
  191. }
  192. ],
  193. "samplers": [
  194. {
  195. "name": "cc_shadow_map_0",
  196. "defines": [
  197. "CC_USE_SHADOW_MAP",
  198. "CC_NUM_SHADOW_LIGHTS"
  199. ]
  200. },
  201. {
  202. "name": "cc_shadow_map_1",
  203. "defines": [
  204. "CC_USE_SHADOW_MAP",
  205. "CC_NUM_SHADOW_LIGHTS"
  206. ]
  207. }
  208. ]
  209. },
  210. "locals": {
  211. "blocks": [
  212. {
  213. "name": "CCLocal",
  214. "defines": []
  215. }
  216. ],
  217. "samplers": []
  218. }
  219. },
  220. "defines": [
  221. {
  222. "name": "CC_USE_SKINNING",
  223. "type": "boolean",
  224. "defines": []
  225. },
  226. {
  227. "name": "CC_USE_JOINTS_TEXTRUE",
  228. "type": "boolean",
  229. "defines": [
  230. "CC_USE_SKINNING"
  231. ]
  232. },
  233. {
  234. "name": "CC_JOINTS_TEXTURE_FLOAT32",
  235. "type": "boolean",
  236. "defines": [
  237. "CC_USE_SKINNING",
  238. "CC_USE_JOINTS_TEXTRUE"
  239. ]
  240. },
  241. {
  242. "name": "CC_USE_ATTRIBUTE_UV0",
  243. "type": "boolean",
  244. "defines": []
  245. },
  246. {
  247. "name": "CC_USE_ATTRIBUTE_COLOR",
  248. "type": "boolean",
  249. "defines": []
  250. },
  251. {
  252. "name": "CC_USE_ATTRIBUTE_NORMAL",
  253. "type": "boolean",
  254. "defines": []
  255. },
  256. {
  257. "name": "CC_USE_ATTRIBUTE_TANGENT",
  258. "type": "boolean",
  259. "defines": []
  260. },
  261. {
  262. "name": "USE_POSITION_SCALING",
  263. "type": "boolean",
  264. "defines": []
  265. },
  266. {
  267. "name": "CC_USE_SHADOW_MAP",
  268. "type": "boolean",
  269. "defines": []
  270. },
  271. {
  272. "name": "CC_NUM_SHADOW_LIGHTS",
  273. "type": "number",
  274. "defines": [
  275. "CC_USE_SHADOW_MAP"
  276. ],
  277. "range": [
  278. 0,
  279. 3
  280. ]
  281. },
  282. {
  283. "name": "CC_NUM_LIGHTS",
  284. "type": "number",
  285. "defines": [],
  286. "range": [
  287. 0,
  288. 3
  289. ]
  290. },
  291. {
  292. "name": "USE_OUTLINE_BASE_COLOR_MAP",
  293. "type": "boolean",
  294. "defines": []
  295. },
  296. {
  297. "name": "CC_NUM_DIR_LIGHTS",
  298. "type": "number",
  299. "defines": [],
  300. "range": [
  301. 0,
  302. 3
  303. ]
  304. },
  305. {
  306. "name": "CC_USE_ALPHA_ATLAS_outlineBaseColorMap",
  307. "type": "boolean",
  308. "defines": [
  309. "USE_OUTLINE_BASE_COLOR_MAP"
  310. ]
  311. },
  312. {
  313. "name": "INPUT_IS_GAMMA",
  314. "type": "boolean",
  315. "defines": [
  316. "USE_OUTLINE_BASE_COLOR_MAP"
  317. ]
  318. }
  319. ],
  320. "blocks": [
  321. {
  322. "name": "SKINNING",
  323. "members": [
  324. {
  325. "name": "jointsTextureSize",
  326. "type": 14,
  327. "count": 1
  328. }
  329. ],
  330. "defines": [
  331. "CC_USE_SKINNING",
  332. "CC_USE_JOINTS_TEXTRUE"
  333. ],
  334. "binding": 0
  335. },
  336. {
  337. "name": "JOINT_MATRIX",
  338. "members": [
  339. {
  340. "name": "jointMatrices",
  341. "type": 26,
  342. "count": 50
  343. }
  344. ],
  345. "defines": [
  346. "CC_USE_SKINNING"
  347. ],
  348. "binding": 1
  349. },
  350. {
  351. "name": "OutlineVert",
  352. "members": [
  353. {
  354. "name": "lineWidth",
  355. "type": 13,
  356. "count": 1
  357. },
  358. {
  359. "name": "depthBias",
  360. "type": 13,
  361. "count": 1
  362. }
  363. ],
  364. "defines": [],
  365. "binding": 2
  366. },
  367. {
  368. "name": "OutlineFrag",
  369. "members": [
  370. {
  371. "name": "outlineBaseColor",
  372. "type": 16,
  373. "count": 1
  374. }
  375. ],
  376. "defines": [],
  377. "binding": 3
  378. }
  379. ],
  380. "samplers": [
  381. {
  382. "name": "jointsTexture",
  383. "type": 29,
  384. "count": 1,
  385. "defines": [
  386. "CC_USE_SKINNING",
  387. "CC_USE_JOINTS_TEXTRUE"
  388. ],
  389. "binding": 30
  390. },
  391. {
  392. "name": "outlineBaseColorMap",
  393. "type": 29,
  394. "count": 1,
  395. "defines": [
  396. "USE_OUTLINE_BASE_COLOR_MAP"
  397. ],
  398. "binding": 31
  399. }
  400. ],
  401. "record": null,
  402. "name": "builtin-toon|outline-vs:vert|outline-fs:frag"
  403. },
  404. {
  405. "hash": 1621866752,
  406. "glsl3": {
  407. "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};\n#if CC_USE_SKINNING\n in vec4 a_weights;\n in vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform SKINNING {\n vec2 jointsTextureSize;\n };\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform JOINT_MATRIX {\n mat4 jointMatrices[50];\n };\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nin vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nin vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nin vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nin vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nin vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nout vec3 v_position;\nout vec2 v_uv;\nout vec3 v_normal;\nout vec3 v_viewDirection;\n#if USE_NORMAL_MAP\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\nuniform ToonVert {\n vec4 tilingOffset;\n};\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 pos = cc_matWorld * In.position;\n v_position = pos.xyz;\n v_uv = In.uv * tilingOffset.xy + tilingOffset.zw;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_position);\n v_normal = (cc_matWorldIT * vec4(In.normal, 0.0)).xyz;\n #if USE_NORMAL_MAP\n v_tangent = normalize((cc_matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }",
  408. "frag": "\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};\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform CC_SHADOW {\n mat4 cc_shadow_lightViewProjMatrix[2];\n vec4 cc_shadow_info[2];\n };\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform CCLIGHTS {\n vec4 cc_lightPositionAndRange[4];\n vec4 cc_lightDirection[4];\n vec4 cc_lightColor[4];\n};\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct ToonSurface {\n vec4 baseColor;\n vec3 specular;\n float specularThreshold;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n vec3 emissive;\n vec3 shadowColor;\n float shadowIntensity;\n vec3 highlightColor;\n float lightThreshold;\n float lightSmoothness;\n};\nconst float T_H = 0.25;\nfloat TreshHoldLighting(float lThreshold, float smoothness, float v) {\n return smoothstep(lThreshold-smoothness*T_H, lThreshold+smoothness*T_H, v);\n}\nLighting toon (ToonSurface s, LightInfo info) {\n Lighting result;\n vec3 N = s.normal;\n vec3 L = info.lightDir;\n vec3 V = s.viewDirection;\n vec3 H = normalize(L + V);\n float NL = 0.5 * dot(N, L) + 0.5;\n float NH = 0.5 * dot(H, N) + 0.5;\n vec3 c = vec3(0.0);\n vec3 attenuation = info.radiance;\n vec3 lightColor = info.lightColor.rgb;\n vec3 shadowColor = mix(s.highlightColor * lightColor, s.shadowColor, s.shadowIntensity);\n vec3 diffuse = TreshHoldLighting(s.lightThreshold, s.lightSmoothness, NL) * attenuation;\n diffuse = mix(shadowColor, s.highlightColor * lightColor, diffuse);\n result.diffuse = diffuse * s.baseColor.rgb;\n float specularWeight = 1.0 - pow(s.specularThreshold, 5.0);\n float specularMask = step(specularWeight, NH);\n vec3 specular = s.specular.rgb * specularMask;\n result.specular = specular * attenuation;\n return result;\n}\nvec3 ambient(ToonSurface s, vec4 ambientColor) {\n return s.baseColor.rgb * ambientColor.rgb;\n}\nvec4 CCToonShading (ToonSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = toon(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = toon(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = toon(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = toon(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n vec3 finalColor = result.diffuse + result.specular + s.emissive;\n return vec4(finalColor, s.baseColor.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec3 v_position;\nin vec2 v_uv;\nin vec3 v_viewDirection;\nin vec3 v_normal;\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\nuniform ToonFrag {\n vec4 colorScale;\n vec4 specular;\n vec4 emissive;\n vec4 shadowColor;\n vec4 highlightColor;\n float specularThreshold;\n float shadowIntensity;\n float lightThreshold;\n float lightSmoothness;\n};\nvoid surf (out ToonSurface s) {\n #if USE_BASE_COLOR_MAP\n s.baseColor = vec4(1.);\n vec4 baseColorMap_tmp = texture(baseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_baseColorMap\n baseColorMap_tmp.a *= texture(baseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.baseColor.rgb *= (baseColorMap_tmp.rgb * baseColorMap_tmp.rgb);\n s.baseColor.a *= baseColorMap_tmp.a;\n #else\n s.baseColor *= baseColorMap_tmp;\n #endif\n #else\n s.baseColor = highlightColor;\n #endif\n s.normal = normalize(v_normal);\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal = normalize(\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * s.normal);\n #endif\n s.position = v_position;\n s.specular = specular.rgb * specular.a;\n #if USE_SPECULAR_MAP\n vec4 specularMap_tmp = texture(specularMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_specularMap\n specularMap_tmp.a *= texture(specularMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularMap_tmp.rgb * specularMap_tmp.rgb);\n #else\n s.specular.rgb *= specularMap_tmp.rgb;\n #endif\n #endif\n s.emissive = emissive.rgb;\n #if USE_EMISSIVE_MAP\n vec4 emissiveMap_tmp = texture(emissiveMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_emissiveMap\n emissiveMap_tmp.a *= texture(emissiveMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveMap_tmp.rgb * emissiveMap_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveMap_tmp.rgb;\n #endif\n #endif\n s.lightThreshold = lightThreshold;\n s.lightSmoothness = lightSmoothness;\n s.shadowColor = shadowColor.rgb;\n s.highlightColor = highlightColor.rgb;\n s.shadowIntensity = shadowIntensity;\n s.specularThreshold = specularThreshold;\n s.viewDirection = v_viewDirection;\n}\nvec4 frag () {\n ToonSurface s;\n surf(s);\n vec4 color = CCToonShading(s);\n return CCFragOutput(color);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"
  409. },
  410. "glsl1": {
  411. "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matWorldIT;\n#if CC_USE_SKINNING\n attribute vec4 a_weights;\n attribute vec4 a_joints;\n #if CC_USE_JOINTS_TEXTRUE\n uniform vec2 jointsTextureSize;\n uniform sampler2D jointsTexture;\n #if CC_JOINTS_TEXTURE_FLOAT32\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 4.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(jointsTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(jointsTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(jointsTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(jointsTexture, vec2(dx * (x + 3.5), y));\n return mat4(v1, v2, v3, v4);\n }\n #else\n float decode32(vec4 rgba) {\n float Sign = 1.0 - step(128.0, rgba[0]) * 2.0;\n float Exponent = 2.0 * mod(rgba[0], 128.0) + step(128.0, rgba[1]) - 127.0;\n float Mantissa = mod(rgba[1], 128.0) * 65536.0 + rgba[2] * 256.0 + rgba[3] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n }\n vec4 decodevec4 (vec4 x, vec4 y, vec4 z, vec4 w) {\n return vec4(\n decode32(x.wzyx * 255.0),\n decode32(y.wzyx * 255.0),\n decode32(z.wzyx * 255.0),\n decode32(w.wzyx * 255.0)\n );\n }\n vec4 decodevec4 (float dx, float x, float y) {\n return decodevec4(\n texture2D(jointsTexture, vec2(dx * (x + 0.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 1.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 2.5), y)),\n texture2D(jointsTexture, vec2(dx * (x + 3.5), y))\n );\n }\n mat4 getBoneMatrix(const in float i) {\n float width = jointsTextureSize.x;\n float height = jointsTextureSize.y;\n float j = i * 16.0;\n float x = mod(j, width);\n float y = floor(j / width);\n float dx = 1.0 / width;\n float dy = 1.0 / height;\n y = dy * (y + 0.5);\n vec4 v1 = decodevec4(dx, x, y);\n vec4 v2 = decodevec4(dx, x+4.0, y);\n vec4 v3 = decodevec4(dx, x+8.0, y);\n vec4 v4 = decodevec4(dx, x+12.0, y);\n return mat4(v1, v2, v3, v4);\n }\n #endif\n #else\n uniform mat4 jointMatrices[50];\n mat4 getBoneMatrix(const in float i) {\n return jointMatrices[int(i)];\n }\n #endif\n mat4 skinMatrix() {\n return\n getBoneMatrix(a_joints.x) * a_weights.x +\n getBoneMatrix(a_joints.y) * a_weights.y +\n getBoneMatrix(a_joints.z) * a_weights.z +\n getBoneMatrix(a_joints.w) * a_weights.w\n ;\n }\n#endif\nstruct StandardVertInput {\n vec2 uv;\n vec4 position;\n vec3 normal;\n vec4 tangent;\n vec4 color;\n};\nattribute vec3 a_position;\n#if CC_USE_ATTRIBUTE_UV0\nattribute vec2 a_uv0;\n#endif\n#if CC_USE_ATTRIBUTE_COLOR\nattribute vec4 a_color;\n#endif\n#if CC_USE_ATTRIBUTE_NORMAL\nattribute vec3 a_normal;\n#endif\n#if CC_USE_ATTRIBUTE_TANGENT\nattribute vec4 a_tangent;\n#endif\nvoid CCAttribute (out StandardVertInput In) {\n In.position = vec4(a_position, 1.0);\n #if CC_USE_ATTRIBUTE_UV0\n In.uv = a_uv0;\n #else\n In.uv = vec2(0.0);\n #endif\n #if CC_USE_ATTRIBUTE_COLOR\n In.color = a_color;\n #else\n In.color = vec4(1.0);\n #endif\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = a_normal;\n #else\n In.normal = vec3(0.0, 1.0, 0.0);\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = a_tangent;\n #else\n In.tangent = vec4(1.0, 0.0, 0.0, 0.0);\n #endif\n}\nvoid CCVertInput(out StandardVertInput In) {\n CCAttribute(In);\n #if CC_USE_SKINNING\n mat4 m = skinMatrix();\n In.position = m * In.position;\n #if CC_USE_ATTRIBUTE_NORMAL\n In.normal = (m * vec4(In.normal, 0)).xyz;\n #endif\n #if CC_USE_ATTRIBUTE_TANGENT\n In.tangent = m * In.tangent;\n #endif\n #endif\n}\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec3 v_normal;\nvarying vec3 v_viewDirection;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\nuniform vec4 tilingOffset;\nvec4 vert () {\n StandardVertInput In;\n CCVertInput(In);\n vec4 pos = cc_matWorld * In.position;\n v_position = pos.xyz;\n v_uv = In.uv * tilingOffset.xy + tilingOffset.zw;\n v_viewDirection = normalize(cc_cameraPos.xyz - v_position);\n v_normal = (cc_matWorldIT * vec4(In.normal, 0.0)).xyz;\n #if USE_NORMAL_MAP\n v_tangent = normalize((cc_matWorldIT * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n return cc_matViewProj * pos;\n}\nvoid main() { gl_Position = vert(); }",
  412. "frag": "\nprecision highp float;\n#if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n uniform vec4 cc_shadow_info[2];\n #if CC_NUM_SHADOW_LIGHTS > 0\n uniform sampler2D cc_shadow_map_0;\n #endif\n #if CC_NUM_SHADOW_LIGHTS > 1\n uniform sampler2D cc_shadow_map_1;\n #endif\n varying vec4 v_posLightSpace[2];\n varying float v_depth[2];\n#endif\nfloat unpackRGBAToDepth(vec4 color) {\n return dot(color, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n}\nfloat getDepth(sampler2D shadowMap, vec2 shadowUV) {\n return unpackRGBAToDepth(texture2D(shadowMap, shadowUV));\n}\nfloat computeFallOff(float shadow, vec2 coords, float frustumEdgeFalloff) {\n return shadow;\n}\nfloat shadowSimple(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness) {\n float closestDepth = getDepth(shadowMap, shadowUV);\n return currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n}\nfloat shadowPCF3X3(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -1; x <= 1; ++x) {\n for (int y = -1; y <= 1; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 9.0;\n return shadow;\n}\nfloat shadowPCF5X5(sampler2D shadowMap, vec2 shadowUV, float currentDepth, float darkness, float shadowSize) {\n float shadow = 0.0;\n for (int x = -2; x <= 2; ++x) {\n for (int y = -2; y <= 2; ++y) {\n float closestDepth = getDepth(shadowMap, shadowUV + vec2(x, y) * 1.0/shadowSize);\n shadow += currentDepth > closestDepth ? 1.0 - darkness : 1.0;\n }\n }\n shadow /= 25.0;\n return shadow;\n}\n#if CC_NUM_LIGHTS > 0\nuniform vec4 cc_lightPositionAndRange[4];\nuniform vec4 cc_lightDirection[4];\nuniform vec4 cc_lightColor[4];\n#endif\nstruct LightInfo {\n vec3 lightDir;\n vec3 radiance;\n vec4 lightColor;\n};\nLightInfo computeDirectionalLighting(\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n ret.lightDir = -normalize(lightDirection.xyz);\n ret.radiance = lightColor.rgb;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computePointLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n ret.lightDir = normalize(lightDir);\n ret.radiance = lightColor.rgb * attenuation;\n ret.lightColor = lightColor;\n return ret;\n}\nLightInfo computeSpotLighting(\n vec3 worldPosition,\n vec4 lightPositionAndRange,\n vec4 lightDirection,\n vec4 lightColor\n) {\n LightInfo ret;\n vec3 lightDir = lightPositionAndRange.xyz - worldPosition;\n float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);\n lightDir = normalize(lightDir);\n float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));\n cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;\n cosConeAngle = pow(cosConeAngle, lightColor.w);\n ret.lightDir = lightDir;\n ret.radiance = lightColor.rgb * attenuation * cosConeAngle;\n ret.lightColor = lightColor;\n return ret;\n}\nstruct Lighting {\n vec3 diffuse;\n vec3 specular;\n};\nstruct ToonSurface {\n vec4 baseColor;\n vec3 specular;\n float specularThreshold;\n vec3 position;\n vec3 normal;\n vec3 viewDirection;\n vec3 emissive;\n vec3 shadowColor;\n float shadowIntensity;\n vec3 highlightColor;\n float lightThreshold;\n float lightSmoothness;\n};\nconst float T_H = 0.25;\nfloat TreshHoldLighting(float lThreshold, float smoothness, float v) {\n return smoothstep(lThreshold-smoothness*T_H, lThreshold+smoothness*T_H, v);\n}\nLighting toon (ToonSurface s, LightInfo info) {\n Lighting result;\n vec3 N = s.normal;\n vec3 L = info.lightDir;\n vec3 V = s.viewDirection;\n vec3 H = normalize(L + V);\n float NL = 0.5 * dot(N, L) + 0.5;\n float NH = 0.5 * dot(H, N) + 0.5;\n vec3 c = vec3(0.0);\n vec3 attenuation = info.radiance;\n vec3 lightColor = info.lightColor.rgb;\n vec3 shadowColor = mix(s.highlightColor * lightColor, s.shadowColor, s.shadowIntensity);\n vec3 diffuse = TreshHoldLighting(s.lightThreshold, s.lightSmoothness, NL) * attenuation;\n diffuse = mix(shadowColor, s.highlightColor * lightColor, diffuse);\n result.diffuse = diffuse * s.baseColor.rgb;\n float specularWeight = 1.0 - pow(s.specularThreshold, 5.0);\n float specularMask = step(specularWeight, NH);\n vec3 specular = s.specular.rgb * specularMask;\n result.specular = specular * attenuation;\n return result;\n}\nvec3 ambient(ToonSurface s, vec4 ambientColor) {\n return s.baseColor.rgb * ambientColor.rgb;\n}\nvec4 CCToonShading (ToonSurface s) {\n Lighting result;\n result.diffuse = vec3(0, 0, 0);\n result.specular = vec3(0, 0, 0);\n #if CC_NUM_LIGHTS > 0\n #if CC_LIGHT_0_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[0]);\n #else\n LightInfo info0;\n #if CC_LIGHT_0_TYPE == 0\n info0 = computeDirectionalLighting(cc_lightDirection[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 1\n info0 = computePointLighting(s.position, cc_lightPositionAndRange[0], cc_lightColor[0]);\n #elif CC_LIGHT_0_TYPE == 2\n info0 = computeSpotLighting(s.position, cc_lightPositionAndRange[0], cc_lightDirection[0], cc_lightColor[0]);\n #endif\n Lighting result0 = toon(s, info0);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 0\n float shadow_0 = 1.0;\n vec2 projCoords0 = v_posLightSpace[0].xy / v_posLightSpace[0].w;\n vec2 shadowUV0 = projCoords0 * 0.5 + vec2(0.5);\n if (shadowUV0.x >= 0.0 && shadowUV0.x <= 1.0 && shadowUV0.y >= 0.0 && shadowUV0.y <= 1.0) {\n float currentDepth0 = clamp(v_depth[0], 0.0, 1.0);\n #if CC_SHADOW_0_TYPE == 3\n shadow_0 = shadowPCF3X3(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #elif CC_SHADOW_0_TYPE == 4\n shadow_0 = shadowPCF5X5(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w, cc_shadow_info[0].z);\n #else\n shadow_0 = shadowSimple(cc_shadow_map_0, shadowUV0, currentDepth0, cc_shadow_info[0].w);\n #endif\n shadow_0 = computeFallOff(shadow_0, projCoords0, 0.0);\n }\n result0.diffuse *= shadow_0;\n result0.specular *= shadow_0;\n #endif\n result.diffuse += result0.diffuse;\n result.specular += result0.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 1\n #if CC_LIGHT_1_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[1]);\n #else\n LightInfo info1;\n #if CC_LIGHT_1_TYPE == 0\n info1 = computeDirectionalLighting(cc_lightDirection[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 1\n info1 = computePointLighting(s.position, cc_lightPositionAndRange[1], cc_lightColor[1]);\n #elif CC_LIGHT_1_TYPE == 2\n info1 = computeSpotLighting(s.position, cc_lightPositionAndRange[1], cc_lightDirection[1], cc_lightColor[1]);\n #endif\n Lighting result1 = toon(s, info1);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 1\n float shadow_1 = 1.0;\n vec2 projCoords1 = v_posLightSpace[1].xy / v_posLightSpace[1].w;\n vec2 shadowUV1 = projCoords1 * 0.5 + vec2(0.5);\n if (shadowUV1.x >= 0.0 && shadowUV1.x <= 1.0 && shadowUV1.y >= 0.0 && shadowUV1.y <= 1.0) {\n float currentDepth1 = clamp(v_depth[1], 0.0, 1.0);\n #if CC_SHADOW_1_TYPE == 3\n shadow_1 = shadowPCF3X3(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #elif CC_SHADOW_1_TYPE == 4\n shadow_1 = shadowPCF5X5(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w, cc_shadow_info[1].z);\n #else\n shadow_1 = shadowSimple(cc_shadow_map_1, shadowUV1, currentDepth1, cc_shadow_info[1].w);\n #endif\n shadow_1 = computeFallOff(shadow_1, projCoords1, 0.0);\n }\n result1.diffuse *= shadow_1;\n result1.specular *= shadow_1;\n #endif\n result.diffuse += result1.diffuse;\n result.specular += result1.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 2\n #if CC_LIGHT_2_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[2]);\n #else\n LightInfo info2;\n #if CC_LIGHT_2_TYPE == 0\n info2 = computeDirectionalLighting(cc_lightDirection[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 1\n info2 = computePointLighting(s.position, cc_lightPositionAndRange[2], cc_lightColor[2]);\n #elif CC_LIGHT_2_TYPE == 2\n info2 = computeSpotLighting(s.position, cc_lightPositionAndRange[2], cc_lightDirection[2], cc_lightColor[2]);\n #endif\n Lighting result2 = toon(s, info2);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 2\n float shadow_2 = 1.0;\n vec2 projCoords2 = v_posLightSpace[2].xy / v_posLightSpace[2].w;\n vec2 shadowUV2 = projCoords2 * 0.5 + vec2(0.5);\n if (shadowUV2.x >= 0.0 && shadowUV2.x <= 1.0 && shadowUV2.y >= 0.0 && shadowUV2.y <= 1.0) {\n float currentDepth2 = clamp(v_depth[2], 0.0, 1.0);\n #if CC_SHADOW_2_TYPE == 3\n shadow_2 = shadowPCF3X3(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #elif CC_SHADOW_2_TYPE == 4\n shadow_2 = shadowPCF5X5(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w, cc_shadow_info[2].z);\n #else\n shadow_2 = shadowSimple(cc_shadow_map_2, shadowUV2, currentDepth2, cc_shadow_info[2].w);\n #endif\n shadow_2 = computeFallOff(shadow_2, projCoords2, 0.0);\n }\n result2.diffuse *= shadow_2;\n result2.specular *= shadow_2;\n #endif\n result.diffuse += result2.diffuse;\n result.specular += result2.specular;\n #endif\n #endif\n #if CC_NUM_LIGHTS > 3\n #if CC_LIGHT_3_TYPE == 3\n result.diffuse += ambient(s, cc_lightColor[3]);\n #else\n LightInfo info3;\n #if CC_LIGHT_3_TYPE == 0\n info3 = computeDirectionalLighting(cc_lightDirection[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 1\n info3 = computePointLighting(s.position, cc_lightPositionAndRange[3], cc_lightColor[3]);\n #elif CC_LIGHT_3_TYPE == 2\n info3 = computeSpotLighting(s.position, cc_lightPositionAndRange[3], cc_lightDirection[3], cc_lightColor[3]);\n #endif\n Lighting result3 = toon(s, info3);\n #if CC_USE_SHADOW_MAP && CC_NUM_SHADOW_LIGHTS > 3\n float shadow_3 = 1.0;\n vec2 projCoords3 = v_posLightSpace[3].xy / v_posLightSpace[3].w;\n vec2 shadowUV3 = projCoords3 * 0.5 + vec2(0.5);\n if (shadowUV3.x >= 0.0 && shadowUV3.x <= 1.0 && shadowUV3.y >= 0.0 && shadowUV3.y <= 1.0) {\n float currentDepth3 = clamp(v_depth[3], 0.0, 1.0);\n #if CC_SHADOW_3_TYPE == 3\n shadow_3 = shadowPCF3X3(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #elif CC_SHADOW_3_TYPE == 4\n shadow_3 = shadowPCF5X5(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w, cc_shadow_info[3].z);\n #else\n shadow_3 = shadowSimple(cc_shadow_map_3, shadowUV3, currentDepth3, cc_shadow_info[3].w);\n #endif\n shadow_3 = computeFallOff(shadow_3, projCoords3, 0.0);\n }\n result3.diffuse *= shadow_3;\n result3.specular *= shadow_3;\n #endif\n result.diffuse += result3.diffuse;\n result.specular += result3.specular;\n #endif\n #endif\n vec3 finalColor = result.diffuse + result.specular + s.emissive;\n return vec4(finalColor, s.baseColor.a);\n}\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec3 v_viewDirection;\nvarying vec3 v_normal;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\nuniform vec4 specular;\nuniform vec4 emissive;\nuniform vec4 shadowColor;\nuniform vec4 highlightColor;\nuniform float specularThreshold;\nuniform float shadowIntensity;\nuniform float lightThreshold;\nuniform float lightSmoothness;\nvoid surf (out ToonSurface s) {\n #if USE_BASE_COLOR_MAP\n s.baseColor = vec4(1.);\n vec4 baseColorMap_tmp = texture2D(baseColorMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_baseColorMap\n baseColorMap_tmp.a *= texture2D(baseColorMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.baseColor.rgb *= (baseColorMap_tmp.rgb * baseColorMap_tmp.rgb);\n s.baseColor.a *= baseColorMap_tmp.a;\n #else\n s.baseColor *= baseColorMap_tmp;\n #endif\n #else\n s.baseColor = highlightColor;\n #endif\n s.normal = normalize(v_normal);\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, v_uv).xyz - vec3(0.5);\n s.normal = normalize(\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_bitangent) +\n nmmp.z * s.normal);\n #endif\n s.position = v_position;\n s.specular = specular.rgb * specular.a;\n #if USE_SPECULAR_MAP\n vec4 specularMap_tmp = texture2D(specularMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_specularMap\n specularMap_tmp.a *= texture2D(specularMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.specular.rgb *= (specularMap_tmp.rgb * specularMap_tmp.rgb);\n #else\n s.specular.rgb *= specularMap_tmp.rgb;\n #endif\n #endif\n s.emissive = emissive.rgb;\n #if USE_EMISSIVE_MAP\n vec4 emissiveMap_tmp = texture2D(emissiveMap, v_uv);\n #if CC_USE_ALPHA_ATLAS_emissiveMap\n emissiveMap_tmp.a *= texture2D(emissiveMap, v_uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n s.emissive.rgb *= (emissiveMap_tmp.rgb * emissiveMap_tmp.rgb);\n #else\n s.emissive.rgb *= emissiveMap_tmp.rgb;\n #endif\n #endif\n s.lightThreshold = lightThreshold;\n s.lightSmoothness = lightSmoothness;\n s.shadowColor = shadowColor.rgb;\n s.highlightColor = highlightColor.rgb;\n s.shadowIntensity = shadowIntensity;\n s.specularThreshold = specularThreshold;\n s.viewDirection = v_viewDirection;\n}\nvec4 frag () {\n ToonSurface s;\n surf(s);\n vec4 color = CCToonShading(s);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }"
  413. },
  414. "builtins": {
  415. "globals": {
  416. "blocks": [
  417. {
  418. "name": "CCGlobal",
  419. "defines": []
  420. },
  421. {
  422. "name": "CC_SHADOW",
  423. "defines": [
  424. "CC_USE_SHADOW_MAP",
  425. "CC_NUM_SHADOW_LIGHTS"
  426. ]
  427. },
  428. {
  429. "name": "CCLIGHTS",
  430. "defines": [
  431. "CC_NUM_LIGHTS"
  432. ]
  433. }
  434. ],
  435. "samplers": [
  436. {
  437. "name": "cc_shadow_map_0",
  438. "defines": [
  439. "CC_USE_SHADOW_MAP",
  440. "CC_NUM_SHADOW_LIGHTS"
  441. ]
  442. },
  443. {
  444. "name": "cc_shadow_map_1",
  445. "defines": [
  446. "CC_USE_SHADOW_MAP",
  447. "CC_NUM_SHADOW_LIGHTS"
  448. ]
  449. }
  450. ]
  451. },
  452. "locals": {
  453. "blocks": [
  454. {
  455. "name": "CCLocal",
  456. "defines": []
  457. }
  458. ],
  459. "samplers": []
  460. }
  461. },
  462. "defines": [
  463. {
  464. "name": "CC_USE_SKINNING",
  465. "type": "boolean",
  466. "defines": []
  467. },
  468. {
  469. "name": "CC_USE_JOINTS_TEXTRUE",
  470. "type": "boolean",
  471. "defines": [
  472. "CC_USE_SKINNING"
  473. ]
  474. },
  475. {
  476. "name": "CC_JOINTS_TEXTURE_FLOAT32",
  477. "type": "boolean",
  478. "defines": [
  479. "CC_USE_SKINNING",
  480. "CC_USE_JOINTS_TEXTRUE"
  481. ]
  482. },
  483. {
  484. "name": "CC_USE_ATTRIBUTE_UV0",
  485. "type": "boolean",
  486. "defines": []
  487. },
  488. {
  489. "name": "CC_USE_ATTRIBUTE_COLOR",
  490. "type": "boolean",
  491. "defines": []
  492. },
  493. {
  494. "name": "CC_USE_ATTRIBUTE_NORMAL",
  495. "type": "boolean",
  496. "defines": []
  497. },
  498. {
  499. "name": "CC_USE_ATTRIBUTE_TANGENT",
  500. "type": "boolean",
  501. "defines": []
  502. },
  503. {
  504. "name": "USE_NORMAL_MAP",
  505. "type": "boolean",
  506. "defines": []
  507. },
  508. {
  509. "name": "CC_USE_SHADOW_MAP",
  510. "type": "boolean",
  511. "defines": []
  512. },
  513. {
  514. "name": "CC_NUM_SHADOW_LIGHTS",
  515. "type": "number",
  516. "defines": [
  517. "CC_USE_SHADOW_MAP"
  518. ],
  519. "range": [
  520. 0,
  521. 3
  522. ]
  523. },
  524. {
  525. "name": "CC_NUM_LIGHTS",
  526. "type": "number",
  527. "defines": [],
  528. "range": [
  529. 0,
  530. 3
  531. ]
  532. },
  533. {
  534. "name": "CC_LIGHT_0_TYPE",
  535. "type": "number",
  536. "defines": [
  537. "CC_NUM_LIGHTS"
  538. ],
  539. "range": [
  540. 0,
  541. 3
  542. ]
  543. },
  544. {
  545. "name": "CC_SHADOW_0_TYPE",
  546. "type": "number",
  547. "defines": [
  548. "CC_NUM_LIGHTS",
  549. "CC_USE_SHADOW_MAP",
  550. "CC_NUM_SHADOW_LIGHTS"
  551. ],
  552. "range": [
  553. 0,
  554. 3
  555. ]
  556. },
  557. {
  558. "name": "CC_LIGHT_1_TYPE",
  559. "type": "number",
  560. "defines": [
  561. "CC_NUM_LIGHTS"
  562. ],
  563. "range": [
  564. 0,
  565. 3
  566. ]
  567. },
  568. {
  569. "name": "CC_SHADOW_1_TYPE",
  570. "type": "number",
  571. "defines": [
  572. "CC_NUM_LIGHTS",
  573. "CC_USE_SHADOW_MAP",
  574. "CC_NUM_SHADOW_LIGHTS"
  575. ],
  576. "range": [
  577. 0,
  578. 3
  579. ]
  580. },
  581. {
  582. "name": "CC_LIGHT_2_TYPE",
  583. "type": "number",
  584. "defines": [
  585. "CC_NUM_LIGHTS"
  586. ],
  587. "range": [
  588. 0,
  589. 3
  590. ]
  591. },
  592. {
  593. "name": "CC_SHADOW_2_TYPE",
  594. "type": "number",
  595. "defines": [
  596. "CC_NUM_LIGHTS",
  597. "CC_USE_SHADOW_MAP",
  598. "CC_NUM_SHADOW_LIGHTS"
  599. ],
  600. "range": [
  601. 0,
  602. 3
  603. ]
  604. },
  605. {
  606. "name": "CC_LIGHT_3_TYPE",
  607. "type": "number",
  608. "defines": [
  609. "CC_NUM_LIGHTS"
  610. ],
  611. "range": [
  612. 0,
  613. 3
  614. ]
  615. },
  616. {
  617. "name": "CC_SHADOW_3_TYPE",
  618. "type": "number",
  619. "defines": [
  620. "CC_NUM_LIGHTS",
  621. "CC_USE_SHADOW_MAP",
  622. "CC_NUM_SHADOW_LIGHTS"
  623. ],
  624. "range": [
  625. 0,
  626. 3
  627. ]
  628. },
  629. {
  630. "name": "OUTPUT_TO_GAMMA",
  631. "type": "boolean",
  632. "defines": []
  633. },
  634. {
  635. "name": "USE_BASE_COLOR_MAP",
  636. "type": "boolean",
  637. "defines": []
  638. },
  639. {
  640. "name": "USE_SPECULAR_MAP",
  641. "type": "boolean",
  642. "defines": []
  643. },
  644. {
  645. "name": "USE_EMISSIVE_MAP",
  646. "type": "boolean",
  647. "defines": []
  648. },
  649. {
  650. "name": "CC_USE_ALPHA_ATLAS_baseColorMap",
  651. "type": "boolean",
  652. "defines": [
  653. "USE_BASE_COLOR_MAP"
  654. ]
  655. },
  656. {
  657. "name": "INPUT_IS_GAMMA",
  658. "type": "boolean",
  659. "defines": [
  660. "USE_BASE_COLOR_MAP"
  661. ]
  662. },
  663. {
  664. "name": "CC_USE_ALPHA_ATLAS_specularMap",
  665. "type": "boolean",
  666. "defines": [
  667. "USE_SPECULAR_MAP"
  668. ]
  669. },
  670. {
  671. "name": "CC_USE_ALPHA_ATLAS_emissiveMap",
  672. "type": "boolean",
  673. "defines": [
  674. "USE_EMISSIVE_MAP"
  675. ]
  676. }
  677. ],
  678. "blocks": [
  679. {
  680. "name": "SKINNING",
  681. "members": [
  682. {
  683. "name": "jointsTextureSize",
  684. "type": 14,
  685. "count": 1
  686. }
  687. ],
  688. "defines": [
  689. "CC_USE_SKINNING",
  690. "CC_USE_JOINTS_TEXTRUE"
  691. ],
  692. "binding": 0
  693. },
  694. {
  695. "name": "JOINT_MATRIX",
  696. "members": [
  697. {
  698. "name": "jointMatrices",
  699. "type": 26,
  700. "count": 50
  701. }
  702. ],
  703. "defines": [
  704. "CC_USE_SKINNING"
  705. ],
  706. "binding": 1
  707. },
  708. {
  709. "name": "ToonVert",
  710. "members": [
  711. {
  712. "name": "tilingOffset",
  713. "type": 16,
  714. "count": 1
  715. }
  716. ],
  717. "defines": [],
  718. "binding": 2
  719. },
  720. {
  721. "name": "ToonFrag",
  722. "members": [
  723. {
  724. "name": "colorScale",
  725. "type": 16,
  726. "count": 1
  727. },
  728. {
  729. "name": "specular",
  730. "type": 16,
  731. "count": 1
  732. },
  733. {
  734. "name": "emissive",
  735. "type": 16,
  736. "count": 1
  737. },
  738. {
  739. "name": "shadowColor",
  740. "type": 16,
  741. "count": 1
  742. },
  743. {
  744. "name": "highlightColor",
  745. "type": 16,
  746. "count": 1
  747. },
  748. {
  749. "name": "specularThreshold",
  750. "type": 13,
  751. "count": 1
  752. },
  753. {
  754. "name": "shadowIntensity",
  755. "type": 13,
  756. "count": 1
  757. },
  758. {
  759. "name": "lightThreshold",
  760. "type": 13,
  761. "count": 1
  762. },
  763. {
  764. "name": "lightSmoothness",
  765. "type": 13,
  766. "count": 1
  767. }
  768. ],
  769. "defines": [],
  770. "binding": 3
  771. }
  772. ],
  773. "samplers": [
  774. {
  775. "name": "jointsTexture",
  776. "type": 29,
  777. "count": 1,
  778. "defines": [
  779. "CC_USE_SKINNING",
  780. "CC_USE_JOINTS_TEXTRUE"
  781. ],
  782. "binding": 30
  783. },
  784. {
  785. "name": "normalMap",
  786. "type": 29,
  787. "count": 1,
  788. "defines": [
  789. "USE_NORMAL_MAP"
  790. ],
  791. "binding": 31
  792. },
  793. {
  794. "name": "baseColorMap",
  795. "type": 29,
  796. "count": 1,
  797. "defines": [
  798. "USE_BASE_COLOR_MAP"
  799. ],
  800. "binding": 32
  801. },
  802. {
  803. "name": "specularMap",
  804. "type": 29,
  805. "count": 1,
  806. "defines": [
  807. "USE_SPECULAR_MAP"
  808. ],
  809. "binding": 33
  810. },
  811. {
  812. "name": "emissiveMap",
  813. "type": 29,
  814. "count": 1,
  815. "defines": [
  816. "USE_EMISSIVE_MAP"
  817. ],
  818. "binding": 34
  819. }
  820. ],
  821. "record": null,
  822. "name": "builtin-toon|toon-vs:vert|toon-fs:frag"
  823. }
  824. ]
  825. }