NLDClient-yudde/ProjectNLD/Assets/Code/Shaders/Others/LightArea.shader

82 lines
1.9 KiB
Plaintext

Shader "Unlit/LightArea"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Alpha ("Alpha", Range(0, 1)) = 1
}
SubShader
{
Tags {
"RenderType" = "Transparent"
"RenderPipeline" = "UniversalPipeline"
}
LOD 100
Pass
{
Name "LightArea"
Tags
{
"LightMode" = "LightArea"
}
// 开启混合
Blend SrcAlpha One
ZWrite Off
ZTest Always
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make gpu instancing work
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
// gpu instance id
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
// gpu instance id
UNITY_VERTEX_INPUT_INSTANCE_ID
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Alpha;
v2f vert (appdata v)
{
v2f o;
// gpu instance id
UNITY_SETUP_INSTANCE_ID(v);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
col *= _Alpha;
return col;
}
ENDCG
}
}
}