urp-hlsl-templates
URP HLSL Shader Code Templates
TRIGGER
Use this skill when the user wants to write a Unity shader in HLSL/ShaderLab code (not Shader Graph) for Universal Render Pipeline. Triggers include: "URP shader", "HLSL", "ShaderLab", "write a shader", "custom shader", "vertex fragment shader", "SRP Batcher", "CBUFFER", "custom lit shader", "unlit shader", or any code-based shader authoring in URP. Also trigger when converting Built-in pipeline shaders to URP, or when the user references Cyanilux templates, phi-lira gists, or NedMakesGames tutorials.
CORE RULES — URP HLSL
-
Always use
HLSLPROGRAM/ENDHLSL, neverCGPROGRAM/ENDCG. URP uses HLSL, not CG. CG blocks will compile but miss URP-specific includes and macros. -
All material properties must be in a
CBUFFER_START(UnityPerMaterial)/CBUFFER_ENDblock for SRP Batcher compatibility. Without this, each material breaks batching and gets its own draw call. -
Include URP Core, not legacy Unity includes.
// CORRECT (URP) #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"