63 lines
1.8 KiB
Plaintext
63 lines
1.8 KiB
Plaintext
Shader "UI/SpeckledEffect"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex ("Main Texture", 2D) = "white" {}
|
|
_SpeckleTex ("Speckle Texture", 2D) = "white" {}
|
|
_SpeckleIntensity ("Speckle Intensity", Range(0, 1)) = 0.5
|
|
_Color ("Color Tint", Color) = (1,1,1,1)
|
|
}
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane"
|
|
}
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata_t
|
|
{
|
|
float4 vertex : POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float2 texcoord : TEXCOORD0;
|
|
float4 vertex : SV_POSITION;
|
|
};
|
|
|
|
sampler2D _MainTex;
|
|
sampler2D _SpeckleTex;
|
|
float _SpeckleIntensity;
|
|
float4 _Color;
|
|
|
|
v2f vert(appdata_t v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.texcoord = v.texcoord;
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag(v2f i) : SV_Target
|
|
{
|
|
// Sample the main texture
|
|
fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
|
|
// Sample the speckle texture and tile it
|
|
fixed4 speckle = tex2D(_SpeckleTex, i.texcoord * 10.0); // Adjust scaling for effect
|
|
// Combine them with speckle affecting the alpha
|
|
col.rgb = lerp(col.rgb, speckle.rgb, _SpeckleIntensity);
|
|
col.a = col.a * (1.0 - _SpeckleIntensity) + speckle.a * _SpeckleIntensity;
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
FallBack "UI/Default"
|
|
} |