您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

93 行
2.2 KiB

Shader "Unlit/HumanStencil"
{
Properties
{
_MainTex ("Main Texture", 2D) = "black" {}
}
SubShader
{
Tags
{
"Queue" = "Geometry"
"RenderType" = "Opaque"
"ForceNoShadowCasting" = "True"
}
Pass
{
Cull Off
ZTest Always
ZWrite Off
Lighting Off
LOD 100
Tags
{
"LightMode" = "Always"
}
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#define real half
#define real3 half3
#define real4 half4
#define TransformObjectToHClip UnityObjectToClipPos
#define DECLARE_TEXTURE2D_FLOAT(texture) UNITY_DECLARE_TEX2D_FLOAT(texture)
#define DECLARE_SAMPLER_FLOAT(sampler)
#define SAMPLE_TEXTURE2D(texture,sampler,texcoord) UNITY_SAMPLE_TEX2D(texture,texcoord)
struct appdata
{
float3 position : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 position : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
struct fragment_output
{
real4 color : SV_Target;
};
CBUFFER_START(DisplayRotationPerFrame)
float4x4 _DisplayRotationPerFrame;
CBUFFER_END
v2f vert (appdata v)
{
v2f o;
o.position = TransformObjectToHClip(v.position);
o.texcoord = mul(float3(v.texcoord, 1.0f), _DisplayRotationPerFrame).xy;
return o;
}
DECLARE_TEXTURE2D_FLOAT(_MainTex);
DECLARE_SAMPLER_FLOAT(sampler_MainTex);
fragment_output frag (v2f i)
{
float stencilValue = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r;
fragment_output o;
o.color = real4(stencilValue, stencilValue, stencilValue, 1.0h);
return o;
}
ENDHLSL
}
}
}