Shader/assets/Resources/effect/Glowing.effect.meta

17 lines
6.8 KiB
Plaintext
Raw Normal View History

2022-07-25 03:11:37 +00:00
{
"ver": "1.0.25",
"uuid": "0f9457ac-e49b-4ec4-bd74-11b0eabbdb4d",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec4 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main()\n{\n gl_Position = cc_matViewProj * a_position;\n uv0 = a_uv0;\n}",
"frag": "\n precision highp float;\n varying vec2 uv0;\n uniform sampler2D texture;\n uniform vec4 u_mixColor;\nuniform float u_edge;\n#if IS_Edge_Blur\n uniform float u_edgeBlur;\n#endif\n#if IS_EdgeGlowing\n uniform float u_offset;\n#endif\n#if USE_EDGE_COLOR\n uniform vec4 u_edgeColor;\n#endif\nvec4 drawCircle() {\n float edge = u_edge;\n float dis = 0.0;\n float offset = 0.0;\n vec2 uv = uv0;\n#if IS_EdgeGlowing\n offset = u_offset;\n uv = vec2(0.5 + (uv0.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (uv0.y - 0.5) * ((offset*2.0) + 1.0));\n#endif\n if ( uv.x < edge )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2(edge, edge) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2(edge, (1.0 - edge)) );\n }\n }\n else if ( uv.x > (1.0 - edge) )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2((1.0 - edge), edge ) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2((1.0 - edge), (1.0 - edge) ) );\n }\n }\n vec4 color = u_mixColor * texture2D(texture,uv);\n vec4 edge_color = color;\n float blur = 0.0;\n #if IS_Edge_Blur\n blur = u_edgeBlur;\n #endif\n #if USE_EDGE_COLOR\n #if USER_TEXTURE_COLOR\n edge_color = u_edgeColor * texture2D(texture,uv);\n #else\n edge_color = u_edgeColor;\n #endif\n #endif\n if(dis > 0.001)\n {\n float gap = edge * blur;\n if(dis <= edge - gap)\n {\n color = color;\n }\n else if(dis <= edge)\n {\n float t = smoothstep(0.,gap,edge-dis);\n color = vec4(edge_color.rgb,t * edge_color.a);\n }else{\n #if IS_EdgeGlowing\n color = vec4(edge_color.rgb, (offset - (dis - edge))/offset);\n #else\n color = vec4(edge_color.rgb,0.);\n #endif\n }\n }\n else\n {\n #if IS_EdgeGlowing\n float absX = abs(uv.x - 0.5);\n if(absX > 0.5)\n {\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else\n {\n float absY = abs(uv.y - 0.5);\n if (absY > 0.5){\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else{\n color = color;\n }\n }\n #else\n color = color;\n #endif\n }\n return color;\n}\n void main()\n {\n vec4 color = drawCircle();\n gl_FragColor = color;\n }"
},
"glsl3": {
"vert": "uniform 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};\nprecision highp float;\nin vec4 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main()\n{\n gl_Position = cc_matViewProj * a_position;\n uv0 = a_uv0;\n}",
"frag": "\n precision highp float;\n in vec2 uv0;\n uniform sampler2D texture;\n uniform ARGS{\n vec4 u_mixColor;\n float u_edge;\n };\n#if IS_Edge_Blur\n uniform ARGS1{\n float u_edgeBlur;\n };\n#endif\n#if IS_EdgeGlowing\n uniform ARGS2{\n float u_offset;\n };\n#endif\n#if USE_EDGE_COLOR\n uniform ARGS3{\n vec4 u_edgeColor;\n };\n#endif\nvec4 drawCircle() {\n float edge = u_edge;\n float dis = 0.0;\n float offset = 0.0;\n vec2 uv = uv0;\n#if IS_EdgeGlowing\n offset = u_offset;\n uv = vec2(0.5 + (uv0.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (uv0.y - 0.5) * ((offset*2.0) + 1.0));\n#endif\n if ( uv.x < edge )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2(edge, edge) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2(edge, (1.0 - edge)) );\n }\n }\n else if ( uv.x > (1.0 - edge) )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2((1.0 - edge), edge ) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2((1.0 - edge), (1.0 - edge) ) );\n }\n }\n vec4 color = u_mixColor * texture2D(texture,uv);\n vec4 edge_color = color;\n float blur = 0.0;\n #if IS_Edge_Blur\n blur = u_edgeBlur;\n #endif\n #if USE_EDGE_COLOR\n #if USER_TEXTURE_COLOR\n edge_color = u_edgeColor * texture2D(texture,uv);\n #else\n edge_color = u_edgeColor;\n #endif\n #endif\n if(dis > 0.001)\n {\n float gap = edge * blur;\n if(dis <= edge - gap)\n {\n color = color;\n }\n else if(dis <= edge)\n {\n float t = smoothstep(0.,gap,edge-dis);\n color = vec4(edge_color.rgb,t * edge_color.a);\n }else{\n #if IS_EdgeGlowing\n color = vec4(edge_color.rgb, (offset - (dis - edge))/offset);\n #else\n color = vec4(edge_color.rgb,0.);\n #endif\n }\n }\n else\n {\n #if IS_EdgeGlowing\n float absX = abs(uv.x - 0.5);\n if(absX > 0.5)\n {\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else\n {\n float absY = abs(uv.y - 0.5);\n if (absY > 0.5){\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else{\n color = color;\n }\n }\n #else\n color = color;\n #endif\n }\n return color;\n}\n void main()\n {\n vec4 color = drawCircle();\n gl_FragColor = color;\n }"
}
}
],
"subMetas": {}
}