Added scrolling texture shader

This commit is contained in:
raccoon
2025-05-17 01:44:44 +05:00
parent dd27a4a795
commit 1c0673d551

View File

@@ -2,15 +2,21 @@ Shader "Custom/CloudsShader"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_ScrollSpeed("Scroll Speed", Vector) = (0.1, 0.1, 0, 0)
_Color("Tint Color", Color) = (1,1,1,1)
_MainTex("Main Texture", 2D) = "white" {}
_MainTexScrollX("Main Texture Scroll X", Float) = 0.001
_MainTexScrollY("Main Texture Scroll Y", Float) = 0.001
_NoiseTex("Noise Texture", 2D) = "white" {}
_NoiseTexScrollX("Noise Texture Scroll X", Float) = 0.001
_NoiseTexScrollY("Noise Texture Scroll Y", Float) = 0.001
_Color("Tint Color", Color) = (0.37, 0.37, 0.37, 1.0)
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend One One // Additive blending
Blend One One // Additive blending
ZWrite Off
Cull Off
@@ -21,8 +27,13 @@ Shader "Custom/CloudsShader"
#pragma fragment frag
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _ScrollSpeed;
half _MainTexScrollX;
half _MainTexScrollY;
sampler2D _NoiseTex;
half _NoiseTexScrollX;
half _NoiseTexScrollY;
float4 _Color;
struct appdata
@@ -33,7 +44,8 @@ Shader "Custom/CloudsShader"
struct v2f
{
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD0;
float2 uv2 : TEXCOORD1;
float4 vertex : SV_POSITION;
};
@@ -41,21 +53,21 @@ Shader "Custom/CloudsShader"
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
// Scroll UVs over time
float2 scroll = _ScrollSpeed.xy * _Time.y;
o.uv = v.uv + scroll;
// Textures scrolling
o.uv1 = v.uv + float2(_MainTexScrollX, _MainTexScrollY) * _Time.y;
o.uv2 = v.uv + float2(_NoiseTexScrollX, _NoiseTexScrollY) * _Time.y;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 tex = tex2D(_MainTex, i.uv) * _Color;
return tex;
fixed4 tex1 = tex2D(_MainTex, i.uv1);
fixed4 tex2 = tex2D(_NoiseTex, i.uv2);
return tex1 * tex2 * _Color;
}
ENDCG
}
}
FallBack "Unlit/Transparent"
}