- Home /
Custom shader converting to urp need help
So I want to achieve Unlit/Transparent Cutout shader effect + adding custom color tint for it, but for urp. I think I've found something https://answers.unity.com/questions/273680/transparent-cutout-shader.html , however it's not urp compatible and not unlit I think. It has the broken pink shader effect. I want to convert it to urp somehow but I need to know what exactly makes the shader pink
Answer by andrew-lukasik · Aug 12, 2020 at 11:43 AM
To make that specific shader yourself:
Download
builtin_shaders.zip
file from https://unity3d.com/unity/whats-new/2020.1.1 underAdditional Resource / Builtin Shaders
(note unity version in the link; change to match yours)Find unlit transparent cutout shader inside the zip archive file (hint: it's
Unlit-AlphaTest.shader
)Modify that shader to suit your need
example
Shader "Unlit/Transparent Cutout Tint" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 100
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _Cutoff;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord) * UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
clip(col.a - _Cutoff);
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
OR
Use shader graph: