88 lines
2.2 KiB
Plaintext
88 lines
2.2 KiB
Plaintext
|
|
Shader "Hide/HIDE_DrawTex"
|
||
|
|
{
|
||
|
|
Properties
|
||
|
|
{
|
||
|
|
_MainTex ("Texture", 2D) = "white" {}
|
||
|
|
_MainColor ("Color", Color) = (1,1,1,1)
|
||
|
|
}
|
||
|
|
SubShader
|
||
|
|
{
|
||
|
|
|
||
|
|
Tags {
|
||
|
|
"RenderType"="Transparent"
|
||
|
|
"RenderPipeline" = "UniversalPipeline"
|
||
|
|
}
|
||
|
|
|
||
|
|
Pass
|
||
|
|
{
|
||
|
|
Name "DrawTex"
|
||
|
|
Cull Off
|
||
|
|
ZTest Off
|
||
|
|
ZClip Off
|
||
|
|
ZWrite Off
|
||
|
|
// BlendOp Multiply
|
||
|
|
Blend SrcAlpha DstColor
|
||
|
|
HLSLPROGRAM
|
||
|
|
#pragma vertex vert
|
||
|
|
#pragma fragment frag
|
||
|
|
|
||
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
|
|
||
|
|
// #include "UnityCG.cginc"
|
||
|
|
|
||
|
|
struct appdata
|
||
|
|
{
|
||
|
|
float4 vertex : POSITION;
|
||
|
|
float3 color : COLOR;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct v2f
|
||
|
|
{
|
||
|
|
float2 uv : TEXCOORD0;
|
||
|
|
float4 vertex : SV_POSITION;
|
||
|
|
float4 color: COLOR;
|
||
|
|
};
|
||
|
|
|
||
|
|
TEXTURE2D(_MainTex);
|
||
|
|
SAMPLER(sampler_MainTex);
|
||
|
|
|
||
|
|
CBUFFER_START(UnityPerMaterial)
|
||
|
|
float4 _MainTex_ST;
|
||
|
|
float4 _MainColor;
|
||
|
|
CBUFFER_END
|
||
|
|
|
||
|
|
// 投影参数
|
||
|
|
// float4 _ProjectionParams;
|
||
|
|
|
||
|
|
// 屏幕参数
|
||
|
|
// float4 _ScreenParams;
|
||
|
|
|
||
|
|
v2f vert (appdata v)
|
||
|
|
{
|
||
|
|
v2f o;
|
||
|
|
o.vertex = v.vertex;
|
||
|
|
o.uv = v.color.xy;
|
||
|
|
o.color.a = v.color.z;
|
||
|
|
// 判断 Y 轴是否需要取反
|
||
|
|
float flipY = _ProjectionParams.x;
|
||
|
|
o.vertex.y *= flipY;
|
||
|
|
return o;
|
||
|
|
}
|
||
|
|
|
||
|
|
float4 frag (v2f i) : SV_Target
|
||
|
|
{
|
||
|
|
// sample the texture
|
||
|
|
float4 col = SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_MainTex, i.uv, 200);
|
||
|
|
col.a *= i.color.a;
|
||
|
|
// col.a *= 200.0 / 255.0 * col.a;
|
||
|
|
col.xyz *= _MainColor.xyz;
|
||
|
|
col.a *= _MainColor.a;
|
||
|
|
// return float4(1,0,0,1);
|
||
|
|
// if (col.a < 0.001) discard;
|
||
|
|
return col;
|
||
|
|
}
|
||
|
|
ENDHLSL
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|