Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demkeys/03d69b92e756ba9864b79c6781be8d21 to your computer and use it in GitHub Desktop.
Save Demkeys/03d69b92e756ba9864b79c6781be8d21 to your computer and use it in GitHub Desktop.
Shader template for creating Unlit shader in Unity's URP.
Shader "Unlit/#NAME#"
{
Properties
{ }
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
Pass
{
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
};
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
return OUT;
}
half4 frag() : SV_Target
{
half4 customColor = half4(0.5, 0, 0, 1);
return customColor;
}
ENDHLSL
}
}
}
This is a shader template to create an Unlit shader for Unity's URP. The boilerplate code for a URP unlit shader is different from that of a Legacy Render Pipeline unlit shader. Mainly the includes, macros and tags, but maybe also a few other things. To use this template download the template file from this gist and place it in the following folder of your Unity Editor's installation:
%EDITOR%\Editor\Data\Resources\ScriptTemplates
This is a very basic unlit shader. You can change the template to suit your needs (additional properties, different pipeline, etc.).
Tested with Unity 2021.3.5f1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment