2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB
Plaintext

Shader "Custom/CharacterTest"
{
Properties
{
_Direction ("Direction", Vector) = (0, 1, 0, 0)
_Intensity ("Intensity", Range(0.0, 1.0)) = 0.5
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent" "RenderType"="Transparent"
}
LOD 100
Cull Off
ZWrite On
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float4 _Direction;
float _Intensity;
struct Input
{
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
float2 center = float2(0.5, 0.5);
float2 dir = normalize(_Direction.xy) * _Intensity;
// Stretch the texture along the given direction vector
float stretch = dot(IN.uv_MainTex - center, _Direction.xy) * _Intensity;
float2 stretchedUV = (IN.uv_MainTex - center) * float2(stretch, 1.0) + center;
fixed4 col = tex2D(_MainTex, stretchedUV);
if (col.a == 0)
{
discard;
}
o.Albedo = col.rgb;
o.Alpha = col.a;
}
ENDCG
}
FallBack "Diffuse"
}