I would love some included shader templates for URP. Currently (in URP 12.1.6) the right click dialog Create â Shader in the project window has the following templates:
All the .shader files here are templates from the built-in pipeline. I think it is about time that we have at least a URP Unlit Shader template. I understand that URP does not currently have a surface shader solution and that ImageEffect shaders arenât used either. However I hope there will be new templates once there is a surface shader solution and URP custom post processing is finalized.
The fact that the current templates do not go higher than shader target 3.0 and all use CG instead of HLSL is a good indicator of how badly we need an update.
NewSurfaceShader.shader
Shader âCustom/NewSurfaceShaderâ
{
Properties
{
_Color (âColorâ, Color) = (1,1,1,1)
_MainTex (âAlbedo (RGB)â, 2D) = âwhiteâ {}
_Glossiness (âSmoothnessâ, Range(0,1)) = 0.5
_Metallic (âMetallicâ, Range(0,1)) = 0.0
}
SubShader
{
Tags { âRenderTypeâ=âOpaqueâ }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
// Add instancing support for this shader. You need to check âEnable Instancingâ on materials that use the shader.
// See Unity - Manual: GPU instancing for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack âDiffuseâ
}
NewImageEffectShader.shader
Shader "Hidden/NewImageEffectShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
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;
}
sampler2D _MainTex;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
// just invert the colors
col.rgb = 1 - col.rgb;
return col;
}
ENDCG
}
}
}
NewUnlitShader.shader
Shader "Unlit/NewUnlitShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f 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
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
New Custom Render Texture.shader
Shader âCustomRenderTexture/New Custom Render Textureâ
{
Properties
{
_Color (âColorâ, Color) = (1,1,1,1)
_MainTex(âInputTexâ, 2D) = âwhiteâ {}
}
SubShader
{
Blend One Zero
Pass
{
Name âNew Custom Render Textureâ
CGPROGRAM
#include âUnityCustomRenderTexture.cgincâ
#pragma vertex CustomRenderTextureVertexShader
#pragma fragment frag
#pragma target 3.0
float4 _Color;
sampler2D _MainTex;
float4 frag(v2f_customrendertexture IN) : COLOR
{
float2 uv = IN.localTexcoord.xy;
float4 color = tex2D(_MainTex, uv) * _Color;
// TODO: Replace this by actual code!
uint2 p = uv.xy * 256;
return countbits(~(p.x & p.y) + 1) % 2 * float4(uv, 1, 1) * color;
}
ENDCG
}
}
}