您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
88 行
2.4 KiB
88 行
2.4 KiB
Shader "LightweightPipeline/Unlit"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Texture", 2D) = "white" {}
|
|
_MainColor("MainColor", Color) = (1, 1, 1, 1)
|
|
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5
|
|
|
|
// BlendMode
|
|
[HideInInspector] _Mode("Mode", Float) = 0.0
|
|
[HideInInspector] _SrcBlend("Src", Float) = 1.0
|
|
[HideInInspector] _DstBlend("Dst", Float) = 0.0
|
|
[HideInInspector] _ZWrite("ZWrite", Float) = 1.0
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "Opaque" "IgnoreProjectors" = "True" "RenderPipeline" = "LightweightPipe" }
|
|
LOD 100
|
|
|
|
Blend [_SrcBlend][_DstBlend]
|
|
ZWrite [_ZWrite]
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
|
|
#pragma multi_compile_fog
|
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
UNITY_FOG_COORDS(1)
|
|
float4 vertex : SV_POSITION;
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
half4 _MainColor;
|
|
half _Cutoff;
|
|
|
|
v2f vert(appdata v)
|
|
{
|
|
v2f o;
|
|
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
|
UNITY_TRANSFER_FOG(o,o.vertex);
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag(v2f i) : SV_Target
|
|
{
|
|
fixed4 texColor = tex2D(_MainTex, i.uv);
|
|
fixed alpha = texColor.a * _MainColor.a;
|
|
fixed3 color = texColor.rgb * _MainColor.rgb;
|
|
|
|
#ifdef _ALPHATEST_ON
|
|
clip(alpha - _Cutoff);
|
|
#endif
|
|
UNITY_APPLY_FOG(i.fogCoord, color);
|
|
|
|
#ifdef _ALPHABLEND_ON
|
|
return fixed4(color, alpha);
|
|
#else
|
|
return fixed4(color, 1.0);
|
|
#endif
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
CustomEditor "LightweightUnlitGUI"
|
|
}
|