// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Custom/Sprites/DefaultShadowIndistinct"
{
Properties
{
[HideInInspector]_MainTex("Main Tex", 2D) = "white" {}
_RadiusX("_RadiusX", Range(0, 2)) = 1
_RadiusY("_RadiusY", Range(0, 2)) = 1
_AlphaX("_AlphaX", Range(0, 1)) = 0.5
_AlphaY("_AlphaY", Range(0, 1)) = 0.5
_ScaleY("_ScaleY", Range(0, 1)) = 0.5
_Offset("Offset", vector) = (0, 0, 0, 0)
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
float _AlphaX;
float _AlphaY;
float _RadiusX;
float _RadiusY;
float _ScaleY;
float4 _Offset;
float4 _MainTex_ST;
struct v2f
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float3 worldPos : TEXCOORD1;
};
v2f vert_normal(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
v2f vert_offset(appdata_base v)
{
v2f o;
float4 pos = mul(unity_ObjectToWorld, v.vertex);
o.pos = mul(UNITY_MATRIX_VP, pos + _Offset);
o.pos.y = o.pos.y * _ScaleY;//贴图压扁
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
//o.uv.y = o.uv.y * _ScaleY;
return o;
}
float4 frag_normal(v2f i) : COLOR
{
float4 texcol = tex2D(_MainTex, i.uv);
return texcol;
}
float4 frag_color(v2f i) : COLOR
{
float4 color = tex2D(_MainTex, i.uv);
//y渐变
//float y = i.uv.y + _Alpha + _UVY;
//color *= float4(0, 0, 0, y);
//圆心渐变
//float radius = ((i.uv.x - 0.5) * (i.uv.x - 0.5) + (i.uv.y - 0.5) * (i.uv.y - 0.5)) * _Radius;
//color *= float4(0, 0, 0, radius + _Alpha);
//x,y渐变
float x2 = (i.uv.x - 0.5) * (i.uv.x - 0.5) * _RadiusX * _AlphaX;
float y2 = (i.uv.y - 0.5) * (i.uv.y - 0.5) * _RadiusY * _AlphaY;
float alpha = (1 - (x2 + y2));
color *= float4(0, 0, 0, alpha);
return color;
}
ENDCG
SubShader
{
Tags{ "Queue" = "Transparent" }
Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert_offset
#pragma fragment frag_color
ENDCG
}
Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert_normal
#pragma fragment frag_normal
ENDCG
}
}
FallBack "Diffuse"
}
贴图阴影shader(模糊渐变)
于 2022-03-03 08:57:00 首次发布