feat(hero): 为英雄 mo4 添加轮廓发光效果

- 新增内置轮廓发光着色器效果文件
- 新增轮廓发光材质并配置红色发光参数
- 在 mo4 英雄预制件中应用轮廓发光材质
- 移除不再需要的嵌套预制件引用以简化结构
This commit is contained in:
panw
2026-03-20 15:44:56 +08:00
parent 8d059a28d4
commit 855d50a98a
7 changed files with 269 additions and 148 deletions

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "8ff03797-013e-42bb-88e1-7596c6c857a4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,41 @@
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "cfeeea4f-db9c-42cd-a0f7-fc5cb37bd3d7",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{
"USE_TEXTURE": true
}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"glowColor": {
"__type__": "cc.Color",
"r": 255,
"g": 20,
"b": 20,
"a": 255
},
"glowWidth": 0.0025,
"glowThreshold": 0.887
}
]
}

View File

@@ -0,0 +1,11 @@
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "2fcd55a9-38ca-45aa-9164-68e48aaf51ce",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "77cf2ad1-b973-4a37-abdf-94b9ce01aafd",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,169 @@
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: sprite-vs:vert
frag: sprite-fs:frag
depthStencilState:
depthTest: false
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
rasterizerState:
cullMode: none
properties:
alphaThreshold: { value: 0.5 }
glowColor: { value: [1, 1, 1, 1], editor: { type: color } }
glowWidth: { value: 0.05, editor: { slide: true, range: [0, 0.3], step: 0.001 } }
glowThreshold: { value: 1, editor: { slide: true, range: [0, 1], step: 0.001 } }
}%
CCProgram sprite-vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
#if USE_LOCAL
#include <builtin/uniforms/cc-local>
#endif
#if SAMPLE_FROM_RT
#include <common/common-define>
#endif
in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 color;
out vec2 uv0;
vec4 vert () {
vec4 pos = vec4(a_position, 1);
#if USE_LOCAL
pos = cc_matWorld * pos;
#endif
#if USE_PIXEL_ALIGNMENT
pos = cc_matView * pos;
pos.xyz = floor(pos.xyz);
pos = cc_matProj * pos;
#else
pos = cc_matViewProj * pos;
#endif
uv0 = a_texCoord;
#if SAMPLE_FROM_RT
CC_HANDLE_RT_SAMPLE_FLIP(uv0);
#endif
color = a_color;
return pos;
}
}%
CCProgram sprite-fs %{
precision highp float;
#include <builtin/internal/embedded-alpha>
#include <builtin/internal/alpha-test>
in vec4 color;
uniform FSConstants {
vec4 glowColor;
float glowWidth;
float glowThreshold;
};
#if USE_TEXTURE
in vec2 uv0;
#pragma builtin(local)
layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture;
#endif
vec4 getTextureColor (sampler2D mainTexture, vec2 uv) {
if (uv.x > 1.0 || uv.x < 0.0 || uv.y > 1.0 || uv.y < 0.0) {
return vec4(0.0, 0.0, 0.0, 0.0);
}
return texture(mainTexture, uv);
}
float getColorAlpha (float angle, float dist) {
// 角度转弧度,公式为:弧度 = 角度 * (pi / 180)
float radian = angle * 3.14 / 180.0;
vec2 newUV = uv0 + vec2(dist * cos(radian), dist * sin(radian));
vec4 color = getTextureColor(cc_spriteTexture, newUV);
return color.a;
}
float getAverageAlpha (float dist) {
float totalAlpha = 0.0;
totalAlpha += getColorAlpha(0.0, dist);
totalAlpha += getColorAlpha(30.0, dist);
totalAlpha += getColorAlpha(60.0, dist);
totalAlpha += getColorAlpha(90.0, dist);
totalAlpha += getColorAlpha(120.0, dist);
totalAlpha += getColorAlpha(150.0, dist);
totalAlpha += getColorAlpha(180.0, dist);
totalAlpha += getColorAlpha(210.0, dist);
totalAlpha += getColorAlpha(240.0, dist);
totalAlpha += getColorAlpha(270.0, dist);
totalAlpha += getColorAlpha(300.0, dist);
totalAlpha += getColorAlpha(330.0, dist);
return totalAlpha * 0.0833;
}
float getGlowAlpha () {
if (glowWidth == 0.0 ) {
return 0.0;
}
float totalAlpha = 0.0;
totalAlpha += getAverageAlpha(glowWidth * 0.1);
totalAlpha += getAverageAlpha(glowWidth * 0.2);
totalAlpha += getAverageAlpha(glowWidth * 0.3);
totalAlpha += getAverageAlpha(glowWidth * 0.4);
totalAlpha += getAverageAlpha(glowWidth * 0.5);
totalAlpha += getAverageAlpha(glowWidth * 0.6);
totalAlpha += getAverageAlpha(glowWidth * 0.7);
totalAlpha += getAverageAlpha(glowWidth * 0.8);
totalAlpha += getAverageAlpha(glowWidth * 0.9);
totalAlpha += getAverageAlpha(glowWidth * 1.0);
return totalAlpha * 0.1;
}
vec4 frag () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
#if IS_GRAY
float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;
o.r = o.g = o.b = gray;
#endif
#endif
float alpha = getGlowAlpha();
if (alpha <= glowThreshold) {
alpha /= glowThreshold;
alpha = -1.0 * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) + 1.0;
} else {
alpha = 0.0;
}
vec4 dstColor = glowColor * alpha;
vec4 scrColor = o;
o = scrColor * scrColor.a + dstColor * (1.0 - scrColor.a);
o *= color;
ALPHA_TEST(o);
return o;
}
}%

View File

@@ -0,0 +1,15 @@
{
"ver": "1.7.1",
"importer": "effect",
"imported": true,
"uuid": "cfeeea4f-db9c-42cd-a0f7-fc5cb37bd3d7",
"files": [
".json"
],
"subMetas": {},
"userData": {
"combinations": [
{}
]
}
}

View File

@@ -26,31 +26,28 @@
},
{
"__id__": 26
},
{
"__id__": 43
}
],
"_active": true,
"_components": [
{
"__id__": 52
"__id__": 43
},
{
"__id__": 54
"__id__": 45
},
{
"__id__": 56
"__id__": 47
},
{
"__id__": 58
"__id__": 49
},
{
"__id__": 60
"__id__": 51
}
],
"_prefab": {
"__id__": 62
"__id__": 53
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -198,7 +195,10 @@
"__prefab": {
"__id__": 8
},
"_customMaterial": null,
"_customMaterial": {
"__uuid__": "2fcd55a9-38ca-45aa-9164-68e48aaf51ce",
"__expectedType__": "cc.Material"
},
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
@@ -794,136 +794,6 @@
"z": 1
}
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 44
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 43
},
"asset": {
"__uuid__": "b02b7a49-ba72-4956-8b7e-31dc476377f1",
"__expectedType__": "cc.Prefab"
},
"fileId": "54R/aYBglLI4Jn5pm++Jx8",
"instance": {
"__id__": 45
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "ed6VStPDNN5L9seHpMcpLs",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 46
},
{
"__id__": 48
},
{
"__id__": 49
},
{
"__id__": 50
},
{
"__id__": 51
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 47
},
"propertyPath": [
"_name"
],
"value": "maxr"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"54R/aYBglLI4Jn5pm++Jx8"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 47
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -21.094,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 47
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 47
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 47
},
"propertyPath": [
"_lscale"
],
"value": {
"__type__": "cc.Vec3",
"x": 2,
"y": 2.5,
"z": 1
}
},
{
"__type__": "cc.UITransform",
"_name": "",
@@ -934,7 +804,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 53
"__id__": 44
},
"_contentSize": {
"__type__": "cc.Size",
@@ -962,7 +832,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 55
"__id__": 46
},
"anm": {
"__id__": 5
@@ -983,7 +853,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 57
"__id__": 48
},
"debugMode": false,
"_id": ""
@@ -1002,7 +872,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 59
"__id__": 50
},
"enabledContactListener": true,
"bullet": false,
@@ -1036,7 +906,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 61
"__id__": 52
},
"tag": 0,
"_group": 4,
@@ -1072,9 +942,6 @@
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 43
},
{
"__id__": 26
},