18 lines
4.0 KiB
Plaintext
18 lines
4.0 KiB
Plaintext
{
|
|
"ver": "1.0.27",
|
|
"uuid": "f6058828-48e1-4b49-bced-e4d78a3c2d59",
|
|
"importer": "effect",
|
|
"compiledShaders": [
|
|
{
|
|
"glsl1": {
|
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nattribute vec2 a_uv0;\nvarying vec4 v_color;\nvarying vec2 v_uv0;\nvoid main () {\n vec4 pos = vec4(a_position, 1.0);\n #if CC_USE_MODEL\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n #else\n gl_Position = cc_matViewProj * pos;\n #endif\n v_color = a_color;\n v_uv0 = a_uv0;\n}",
|
|
"frag": "\nprecision highp float;\nvarying vec4 v_color;\nvarying vec2 v_uv0;\nuniform sampler2D texture;\nuniform vec4 outlineColor;\nuniform vec2 imageSize;\nuniform float outlineWidth;\nvec4 sampleAt (vec2 point) {\n vec2 uv = point / imageSize;\n if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return vec4(0.0);\n vec4 color = vec4(1.0);\n vec4 texture_tmp = texture2D(texture, uv);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n return color;\n}\nvoid main () {\n vec2 point = v_uv0 * (imageSize + vec2(4.0)) - vec2(2.0);\n vec4 fill = sampleAt(point);\n float expanded = fill.a;\n for (int i = 0; i < 16; i++) {\n float angle = float(i) * 0.3926990817;\n vec2 offset = vec2(cos(angle), sin(angle)) * outlineWidth;\n expanded = max(expanded, sampleAt(point + offset).a);\n }\n float border = expanded * outlineColor.a * (1.0 - fill.a);\n float alpha = fill.a + border;\n vec3 rgb = (fill.rgb * fill.a + outlineColor.rgb * border) / max(alpha, 0.00001);\n vec4 color = vec4(rgb * v_color.rgb, alpha * v_color.a);\n #if USE_BGRA\n gl_FragColor = color.bgra;\n #else\n gl_FragColor = color;\n #endif\n}"
|
|
},
|
|
"glsl3": {
|
|
"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;\nin vec2 a_uv0;\nout vec4 v_color;\nout vec2 v_uv0;\nvoid main () {\n vec4 pos = vec4(a_position, 1.0);\n #if CC_USE_MODEL\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n #else\n gl_Position = cc_matViewProj * pos;\n #endif\n v_color = a_color;\n v_uv0 = a_uv0;\n}",
|
|
"frag": "\nprecision highp float;\nin vec4 v_color;\nin vec2 v_uv0;\nuniform sampler2D texture;\nuniform Outline {\n vec4 outlineColor;\n vec2 imageSize;\n float outlineWidth;\n};\nvec4 sampleAt (vec2 point) {\n vec2 uv = point / imageSize;\n if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return vec4(0.0);\n vec4 color = vec4(1.0);\n vec4 texture_tmp = texture(texture, uv);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n return color;\n}\nvoid main () {\n vec2 point = v_uv0 * (imageSize + vec2(4.0)) - vec2(2.0);\n vec4 fill = sampleAt(point);\n float expanded = fill.a;\n for (int i = 0; i < 16; i++) {\n float angle = float(i) * 0.3926990817;\n vec2 offset = vec2(cos(angle), sin(angle)) * outlineWidth;\n expanded = max(expanded, sampleAt(point + offset).a);\n }\n float border = expanded * outlineColor.a * (1.0 - fill.a);\n float alpha = fill.a + border;\n vec3 rgb = (fill.rgb * fill.a + outlineColor.rgb * border) / max(alpha, 0.00001);\n vec4 color = vec4(rgb * v_color.rgb, alpha * v_color.a);\n #if USE_BGRA\n gl_FragColor = color.bgra;\n #else\n gl_FragColor = color;\n #endif\n}"
|
|
}
|
|
}
|
|
],
|
|
"subMetas": {}
|
|
} |