写一个高光shaderlab
时间: 2024-03-25 09:25:29 浏览: 105
实现各种颜色高亮闪烁的Shader
4星 · 用户满意度95%
Shader "Custom/Glitter" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_GlitterColor ("Glitter Color", Color) = (1, 1, 1, 1)
_GlitterStrength ("Glitter Strength", Range(0,1)) = 0.5
_GlitterSize ("Glitter Size", Range(0,0.1)) = 0.05
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
CGPROGRAM
#pragma surface surf Standard
sampler2D _MainTex;
float _Glossiness;
float _Metallic;
fixed4 _GlitterColor;
float _GlitterStrength;
float _GlitterSize;
struct Input {
float2 uv_MainTex;
float3 worldPos;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutputStandard o) {
// Calculate the base color and glossiness
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
// Add glitter effect
float glitter = smoothstep(0.0, _GlitterSize, sin(dot(IN.worldPos, IN.worldNormal) * 100.0));
o.Emission = glitter * _GlitterStrength * _GlitterColor.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
阅读全文