shader修改
This commit is contained in:
1 parent
5bf02177df
commit
ae5c4212dc
16 files changed
+725
-25
No files matched your search
@@ -38,6 +38,7 @@ Properties {
|
||||
[UIMaskChannel] _DissolveChannel("通道", Float) = 3
|
||||
_Dissolve ("溶解进度", Range(0, 1.01)) = 0
|
||||
_DissolveWidth ("溶解宽度", Range(0, 1)) = 0
|
||||
[CustomDataChannel] _DissolveCustomChannel ("自定义数据通道", Float) = 0
|
||||
// 默认黑色 = 不叠加任何颜色,保证新参数不影响原有溶解效果
|
||||
[HDR]_DissolveEdgeColor ("溶解边缘颜色", Color) = (0, 0, 0, 1)
|
||||
_DissolveEdgeSharpness ("边缘锐度 (越大越细)", Range(0.001, 8)) = 2
|
||||
@@ -130,6 +131,7 @@ Category {
|
||||
float _DissolveChannel;
|
||||
fixed _Dissolve;
|
||||
fixed _DissolveWidth;
|
||||
float _DissolveCustomChannel;
|
||||
fixed4 _DissolveEdgeColor;
|
||||
fixed _DissolveEdgeSharpness;
|
||||
fixed4 _DissolveHighlightColor;
|
||||
@@ -144,6 +146,15 @@ Category {
|
||||
return dot(c, w);
|
||||
}
|
||||
|
||||
// 通用模块:按通道号取粒子自定义数据(供"自定义数据通道"下拉框使用)
|
||||
// channel: 0 = null(返回 0),1~4 = Custom1.xyzw,5~8 = Custom2.xyzw
|
||||
inline float CustomDataChannelValue(float4 custom1, float4 custom2, float channel)
|
||||
{
|
||||
float4 w1 = 1.0 - saturate(abs(channel - float4(1.0, 2.0, 3.0, 4.0)));
|
||||
float4 w2 = 1.0 - saturate(abs(channel - float4(5.0, 6.0, 7.0, 8.0)));
|
||||
return dot(custom1, w1) + dot(custom2, w2);
|
||||
}
|
||||
|
||||
#if _USEUIMASKCLIP_ON
|
||||
fixed4 _ClipRect;
|
||||
#endif
|
||||
@@ -156,7 +167,10 @@ Category {
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
fixed4 texcoord : TEXCOORD0;
|
||||
// 顶点流约定(渲染器 → 自定义顶点流,按此顺序):UV, Custom1.xyzw, Custom2.xyzw
|
||||
float4 texcoord : TEXCOORD0; // UV.xy + Custom1.xy
|
||||
float4 texcoord1 : TEXCOORD1; // Custom1.zw + Custom2.xy
|
||||
float4 texcoord2 : TEXCOORD2; // Custom2.zw
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
@@ -165,6 +179,9 @@ Category {
|
||||
fixed4 color : COLOR;
|
||||
fixed4 texcoord : TEXCOORD0;
|
||||
|
||||
float4 customData : TEXCOORD1; // Custom1.xyzw
|
||||
float4 customData2 : TEXCOORD6; // Custom2.xyzw
|
||||
|
||||
#if _USEMASK_ON
|
||||
fixed2 texcoordMask : TEXCOORD2;
|
||||
#endif
|
||||
@@ -202,6 +219,10 @@ Category {
|
||||
o.texcoord.xy = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
o.texcoord.zw = v.texcoord.zw;
|
||||
|
||||
// 把打包在各 texcoord 里的粒子自定义数据还原成 Custom1.xyzw / Custom2.xyzw
|
||||
o.customData = float4(v.texcoord.z, v.texcoord.w, v.texcoord1.x, v.texcoord1.y);
|
||||
o.customData2 = float4(v.texcoord1.z, v.texcoord1.w, v.texcoord2.x, v.texcoord2.y);
|
||||
|
||||
#if _USEMASK_ON
|
||||
o.texcoordMask = TRANSFORM_TEX(v.texcoord,_Mask);
|
||||
#endif
|
||||
@@ -250,7 +271,11 @@ Category {
|
||||
#endif
|
||||
|
||||
#if _USEDISSOLVE_ON
|
||||
fixed DissolveWithParticle =(_Dissolve*(1-i.texcoord.z)*(1+_DissolveWidth)-_DissolveWidth) ;
|
||||
// 溶解进度 = 滑条 × 选中的自定义数据通道;通道 = null 时完全用滑条(保持原行为)
|
||||
fixed customProgress = CustomDataChannelValue(i.customData, i.customData2, _DissolveCustomChannel);
|
||||
fixed useCustom = step(0.5, _DissolveCustomChannel);
|
||||
fixed dissolveProgress = _Dissolve * lerp(1.0, customProgress, useCustom);
|
||||
fixed DissolveWithParticle =(dissolveProgress*(1+_DissolveWidth)-_DissolveWidth) ;
|
||||
fixed dissolveMap = UIMaskSampleChannel(_DissolveTex, i.texcoordDissolve, _DissolveChannel);
|
||||
fixed dissolveAlpha = saturate(smoothstep( DissolveWithParticle, (DissolveWithParticle+_DissolveWidth), dissolveMap));
|
||||
col.a *= dissolveAlpha;
|
||||
|
||||
Reference in new issue
Block a user