This commit is contained in:
ruanwujing
2024-02-04 16:08:11 +08:00
parent 480933eb02
commit eb5bd5307d
17 changed files with 2338 additions and 2 deletions

View File

@@ -0,0 +1,138 @@
// 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:
rows: {value: 4}
columns: {value: 8}
sizeExpand: {value: 0.6}
radius: {value: 0.15}
}%
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 "../chunks/sdf2d"
uniform Const {
float rows;
float columns;
float sizeExpand;
float radius;
};
in vec4 color;
in vec2 uv0;
float smin(float a,float b,float k){
float h = clamp(0.5+0.5*(a-b)/k,0.0,1.0);
return mix(a,b,h)-k*h*(1.0-h);
}
float smax(float a,float b,float k){
return -smin(-a,-b,k);
}
float isOdd(float x) {
return fract(x/2.0) * 2.0;
}
#pragma builtin(local)
layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture;
vec4 frag () {
vec4 o = vec4(1, 1, 1, 1);
vec2 id = floor(uv0 * vec2(columns, rows));
vec2 uv_center = (id + 0.5) / vec2(columns, rows);
float exp = sizeExpand + 1.0;
vec2 uv = (uv0 - uv_center) * vec2(columns, rows) * exp;
o *= CCSampleWithAlphaSeparated(cc_spriteTexture, (uv0 - uv_center) * exp + uv_center);
float d = sdBox(uv, vec2(0.5, 0.5));
float rad = radius;
float dd = 0.1;
float odd = isOdd(id.x + id.y);
float s = sign(odd - 0.5);
float dc_top = sdCircle(uv + vec2(0, 0.5 - dd * s), rad);
float dc_bottom = sdCircle(uv + vec2(0, -0.5 + dd * s), rad);
float dc_left = sdCircle(uv + vec2(0.5 + dd * s, 0), rad);
float dc_right = sdCircle(uv + vec2(-0.5 - dd * s, 0), rad);
float k = 0.02;
float nOdd = 1.0 - odd;
float dt = smax(d, -dc_top, k) * odd + smin(d, dc_top , k) * nOdd;
float edge = step(id.y, 0.5);
d = dt * (1.0 - edge) + d * edge;
float db = smax(d, -dc_bottom, k) * odd + smin(d, dc_bottom, k) * nOdd;
edge = step(rows - 1.5, id.y);
d = db * (1.0 - edge) + d * edge;
float dl = smin(d, dc_left, k) * odd + smax(d, -dc_left, k) * nOdd;
edge = step(id.x, 0.5);
d = dl * (1.0 - edge) + d * edge;
float dr = smin(d, dc_right, k) * odd + smax(d, -dc_right, k) * nOdd;
edge = step(columns - 1.5, id.x);
d = dr * (1.0 - edge) + d * edge;
float c = smoothstep(0.01, -0.01, d);
o *= c;
return o;
}
}%

View File

@@ -0,0 +1,11 @@
{
"ver": "1.7.1",
"importer": "effect",
"imported": true,
"uuid": "8db6f7be-b91e-44ba-be47-5857f763dcc2",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,32 @@
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "8db6f7be-b91e-44ba-be47-5857f763dcc2",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 0,
"_defines": [
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"rows": 6,
"columns": 10
}
]
}

View File

@@ -0,0 +1,11 @@
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "0080e1e8-609b-41f2-ad39-2a1c3fb9b4dc",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.50",
"importer": "scene",
"imported": true,
"uuid": "946213b2-dc04-4756-8c82-e9df6ac4d571",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "7a473951-f04b-4028-8ec6-741d8319818f",
"files": [],
"subMetas": {},
"userData": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

View File

@@ -0,0 +1,134 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "10336bef-42f1-4bfd-a795-1f29554ccdd8",
"files": [
".jpeg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "10336bef-42f1-4bfd-a795-1f29554ccdd8@6c48a",
"displayName": "cyberpunk",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "10336bef-42f1-4bfd-a795-1f29554ccdd8",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "10336bef-42f1-4bfd-a795-1f29554ccdd8@f9941",
"displayName": "cyberpunk",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 800,
"height": 480,
"rawWidth": 800,
"rawHeight": 480,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": false,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-400,
-240,
0,
400,
-240,
0,
-400,
240,
0,
400,
240,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
480,
800,
480,
0,
0,
800,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-400,
-240,
0
],
"maxPos": [
400,
240,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "10336bef-42f1-4bfd-a795-1f29554ccdd8@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": false,
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false,
"redirect": "10336bef-42f1-4bfd-a795-1f29554ccdd8@f9941"
}
}