From 22bbc32fee185ea239342643c6f16047b241e12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Wed, 27 Nov 2024 22:12:41 +0800 Subject: [PATCH] shader --- Assets/mat/SubShader.shader | 51 ++++++++++++++++++++++++++++++++ Assets/mat/SubShader.shader.meta | 10 +++++++ 2 files changed, 61 insertions(+) create mode 100644 Assets/mat/SubShader.shader create mode 100644 Assets/mat/SubShader.shader.meta diff --git a/Assets/mat/SubShader.shader b/Assets/mat/SubShader.shader new file mode 100644 index 00000000..f31d643e --- /dev/null +++ b/Assets/mat/SubShader.shader @@ -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" +} diff --git a/Assets/mat/SubShader.shader.meta b/Assets/mat/SubShader.shader.meta new file mode 100644 index 00000000..c5a067c6 --- /dev/null +++ b/Assets/mat/SubShader.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 93de9b44dfdccff48999928f1bcef462 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: