52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
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"
|
|
}
|