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

82 lines
2.0 KiB
Plaintext

Shader "Unlit/LightArea_SRP"
{
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"
"UniversalMaterialType" = "SimpleLit"
}
// 开启混合
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest Always
Cull Off
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct appdata
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 positionHCS : SV_POSITION;
float passAlpha : COLOR1;
};
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float _Alpha;
CBUFFER_END
v2f vert (appdata v)
{
v2f o;
o.positionHCS = TransformObjectToHClip(v.positionOS.xyz);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.passAlpha = _Alpha;
return o;
}
half4 frag (v2f i) : SV_Target
{
// sample the texture
half4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
col *= i.passAlpha;
return col;
}
ENDHLSL
}
}
// Fallback "Universal Render Pipeline/Unlit"
}