// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/FlatTransparent" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "False" "RenderType" = "Transparent" }
/////////////////////////////////////////////////////////
/// First Pass
/////////////////////////////////////////////////////////
Pass {
// Only render alpha channel
ColorMask A
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _Color;
float4 vert(float4 vertex : POSITION) : SV_POSITION {
return UnityObjectToClipPos(vertex);
}
fixed4 frag() : SV_Target {
return _Color;
}
ENDCG
}
/////////////////////////////////////////////////////////
/// Second Pass
/////////////////////////////////////////////////////////
Pass {
// Now render color channel
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
fixed4 _Color;
struct appdata {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert(appdata v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag(v2f i) : SV_Target{
fixed4 col = _Color * tex2D(_MainTex, i.uv);
return col;
}
ENDCG
}
}
Fallback "Diffuse"
}
출처: answers.unity.com/questions/290333/transparent-solid-color-shader.html
'부스러기 > Unity' 카테고리의 다른 글
[WebGL] 모바일 미지원 알림 제거 Unity 2019.4 이하 (0) | 2020.11.27 |
---|---|
유니티 오브젝트 회전방법들 (0) | 2016.08.16 |
화면좌표를 이용하여 RectTransform의 localposition을 구할때 (0) | 2015.12.17 |
모바일에서 파일 입출력 (0) | 2015.12.14 |