How to use this tessellation cginc with URP?

Here’s the code from Catlike Coding:

I’ve been trying to look up how to use this for a grass shader for URP, without any luck.

First of all, can I include cginc files in HLSLPROGRAM?

And I’m getting errors about UNITY_domain and company not being defined, but I’m having a hard time finding what they should be replaced with for them to work in HLSLPROGRAM.

Any help or just small pointers would be very appreciated!

ps: what I’m trying to do overall is add tessellation to this shader: https://twitter.com/Cyanilux/status/1255870774558232582

Whilst you can include CG files in HLSL, that whole include script is already basically in HLSL, so you can just convert the file extension from ‘.cginc’ to ‘.hlsl’ and use that instead. As for the errors, ‘UNITY_domain’ etc. are macros that expand to the relative tessellation keywords on platforms that support it and are defined in the legacy “HLSLSupport.cginc” which used to be automatically included with any CGPROGRAM. All you need to do to get that to work here however is to just copy those defines into the beginning of the tessellation include;

// Tessellation programs based on this article by Catlike Coding:
// https://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/

#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL)
#define UNITY_CAN_COMPILE_TESSELLATION 1
#   define UNITY_domain                 domain
#   define UNITY_partitioning           partitioning
#   define UNITY_outputtopology         outputtopology
#   define UNITY_patchconstantfunc      patchconstantfunc
#   define UNITY_outputcontrolpoints    outputcontrolpoints
#endif

struct vertexInput
{
	float4 vertex : POSITION;
	float3 normal : NORMAL;
	float4 tangent : TANGENT;
};

...