初步加入描边文件

This commit is contained in:
caizhitao 2019-12-11 23:00:33 +08:00
parent 9a7e3858cc
commit 7757f8d8d1
7 changed files with 69 additions and 11 deletions

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"printWidth": 150,
"tabWidth": 4
}

View File

@ -77,6 +77,7 @@ CCProgram fs %{
ALPHA_TEST(o); ALPHA_TEST(o);
gl_FragColor = o; // gl_FragColor = o;
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
} }
}% }%

View File

@ -5,11 +5,11 @@
{ {
"glsl1": { "glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n", "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n}\n" "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n}\n"
}, },
"glsl3": { "glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\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\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n", "vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\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\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n}\n" "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n}\n"
} }
} }
], ],

View File

@ -78,16 +78,16 @@
"__id__": 8 "__id__": 8
}, },
{ {
"__id__": 10 "__id__": 11
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 12 "__id__": 13
}, },
{ {
"__id__": 13 "__id__": 14
} }
], ],
"_prefab": null, "_prefab": null,
@ -177,7 +177,7 @@
"array": [ "array": [
0, 0,
0, 0,
324.7595264191645, 554.2562584220408,
0, 0,
0, 0,
0, 0,
@ -372,6 +372,9 @@
"_components": [ "_components": [
{ {
"__id__": 9 "__id__": 9
},
{
"__id__": 10
} }
], ],
"_prefab": null, "_prefab": null,
@ -432,7 +435,7 @@
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
{ {
"__uuid__": "ca058f99-941b-40f2-b208-d776de59abed" "__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
} }
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
@ -454,6 +457,16 @@
"_atlas": null, "_atlas": null,
"_id": "c5wu68mipC4qBjTD+u0rFa" "_id": "c5wu68mipC4qBjTD+u0rFa"
}, },
{
"__type__": "93154zKEUxNspOL91D2hv6b",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_id": "4aQ0ah9X1FT4GFrlS5JCi9"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "HelloLabel", "_name": "HelloLabel",
@ -465,7 +478,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 11 "__id__": 12
} }
], ],
"_prefab": null, "_prefab": null,
@ -521,7 +534,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 10 "__id__": 11
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -572,7 +585,7 @@
}, },
"_enabled": true, "_enabled": true,
"label": { "label": {
"__id__": 11 "__id__": 12
}, },
"text": "hello", "text": "hello",
"_id": "aa8ulaDR9JcbRoT7r3pqZq" "_id": "aa8ulaDR9JcbRoT7r3pqZq"

View File

@ -0,0 +1,21 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class SpriteOutlineCtrl extends cc.Component {
private _sprite: cc.Sprite = null;
onLoad() {
this._sprite = this.getComponent(cc.Sprite);
if (this._sprite == null) {
throw new Error(`${this.name} can only bind on Sprite`);
}
}
start() {
// let material: cc.Material = this._sprite.getMaterial(0);
// material.setProperty("test", 0);
// this._sprite.setMaterial(0, material);
}
// update (dt) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "93154cca-114c-4db2-938b-f750f686fe9b",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

10
creator.d.ts vendored
View File

@ -13601,6 +13601,16 @@ declare namespace cc {
/** !#en Material Asset. /** !#en Material Asset.
!#zh */ !#zh */
export class Material extends Asset { export class Material extends Asset {
/**
*
* @param {string} name
* @param {Object} val
*/
setProperty (name, val, force?);
/**
*
*/
getProperty (name);
} }
/** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
!#zh EditBox */ !#zh EditBox */