feat: 双Pass膨胀描边shader替代LineRenderer
- 新增 Custom/OutlineUnlit shader: Pass1膨胀描边(Cull Front)+Pass2内芯填充 - BlueOutline.mat: 蓝色描边+半透蓝填充 - TouchPositionHandler改用MeshRenderer.enabled闪烁 - 球体挂MeshRenderer+Outline材质,0.4s闪烁
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
Shader "Custom/OutlineUnlit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainColor ("Main Color", Color) = (0.1, 0.3, 0.8, 0.3)
|
||||
_OutlineColor ("Outline Color", Color) = (0.2, 0.5, 1, 1)
|
||||
_OutlineWidth ("Outline Width", Range(0, 0.3)) = 0.08
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
|
||||
// Pass 1: 膨胀描边
|
||||
Pass
|
||||
{
|
||||
Name "OUTLINE"
|
||||
Cull Front
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float _OutlineWidth;
|
||||
float4 _OutlineColor;
|
||||
|
||||
struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; };
|
||||
struct v2f { float4 pos : SV_POSITION; };
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
float3 n = normalize(v.normal);
|
||||
v.vertex.xyz += n * _OutlineWidth;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target { return _OutlineColor; }
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// Pass 2: 内芯填充
|
||||
Pass
|
||||
{
|
||||
Name "FILL"
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _MainColor;
|
||||
|
||||
struct appdata { float4 vertex : POSITION; };
|
||||
struct v2f { float4 pos : SV_POSITION; };
|
||||
|
||||
v2f vert(appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); return o; }
|
||||
fixed4 frag(v2f i) : SV_Target { return _MainColor; }
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f9df7221aff6471e9c94f9880c6b198
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user