This commit is contained in:
杨号敬 2024-11-27 22:12:41 +08:00
parent a7b1782755
commit 22bbc32fee
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,51 @@
Shader "Custom/SubShader"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_GlowColor ("Glow Color", Color) = (1, 1, 1, 1)
_GlowPower ("Glow Power", Range(0, 10)) = 1
_BlinkSpeed ("Blink Speed", Range(0.1, 10)) = 1
_BlinkIntensity ("Blink Intensity", Range(0, 1)) = 0.5
}
SubShader
{
Tags { "RenderType" = "Opaque" "Queue" = "Geometry+1" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _GlowColor;
float _GlowPower;
float _BlinkSpeed;
float _BlinkIntensity;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
// 获取时间变量,用于控制闪烁
float time = _Time.y;
// 根据时间和闪烁速度计算闪烁因子
float blinkFactor = sin(time * _BlinkSpeed);
// 根据闪烁因子和强度调整发光强度
float adjustedGlowPower = _GlowPower * (1 + blinkFactor * _BlinkIntensity);
// 计算发光效果
half3 glow = _GlowColor.rgb * adjustedGlowPower;
o.Emission = glow;
}
ENDCG
}
FallBack "Diffuse"
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 93de9b44dfdccff48999928f1bcef462
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant: