91 lines
1.9 KiB
Plaintext
91 lines
1.9 KiB
Plaintext
Shader "Sprites/ScrollingNoise"
|
|
{
|
|
Properties
|
|
{
|
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
|
_Color("Tint", Color) = (1,1,1,1)
|
|
|
|
[Header(Scrolling Noise)]
|
|
_NoiseTex("Noise Texture", 2D) = "white" {}
|
|
_SpeedX("Scroll Speed X", Range(-20,20)) = 0.003
|
|
_SpeedY("Scroll Speed Y", Range(-20,20)) = 0.003
|
|
_NoiseIntensity("Noise Intensity", Range(0,1)) = 0.5
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"Queue" = "Transparent"
|
|
"IgnoreProjector" = "True"
|
|
"RenderType" = "Transparent"
|
|
"PreviewType" = "Plane"
|
|
"CanUseSpriteAtlas" = "True"
|
|
}
|
|
Cull Off
|
|
Lighting Off
|
|
ZWrite Off
|
|
Blend One OneMinusSrcAlpha
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata_t
|
|
{
|
|
float4 vertex : POSITION;
|
|
float4 color : COLOR;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
fixed4 color : COLOR;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
fixed4 _Color;
|
|
|
|
sampler2D _NoiseTex;
|
|
uniform float4 _NoiseTex_ST;
|
|
float _SpeedX;
|
|
float _SpeedY;
|
|
float _NoiseIntensity;
|
|
|
|
|
|
v2f vert(appdata_t IN)
|
|
{
|
|
v2f OUT;
|
|
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
|
OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex);
|
|
OUT.color = IN.color;
|
|
return OUT;
|
|
}
|
|
|
|
fixed4 frag(v2f IN) : SV_Target
|
|
{
|
|
// Sample the base sprite texture
|
|
fixed4 col = tex2D(_MainTex, IN.texcoord) * _Color;
|
|
|
|
// Compute scrolling noise coordinates using _Time.x
|
|
float2 noiseUV = TRANSFORM_TEX(IN.texcoord, _NoiseTex) + float2(_Time.x * _SpeedX, _Time.x * _SpeedY);
|
|
|
|
fixed4 noise = tex2D(_NoiseTex, noiseUV);
|
|
|
|
// Blend the noise effect with the sprite.
|
|
// You can adjust blending; here we use a linear interpolation
|
|
col.rgb = lerp(col.rgb, noise.rgb, _NoiseIntensity);
|
|
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|