Hello I work on a UI based, mobile game and we're using URP. I'm not used to writing URP shaders and want to ask a few questions it. 1. Can I use normal syntax using this shader as a base? 2. What is the difference between using tex2D and and SAMPLE_TEXTURE2D, we're building for both android and iPhone. 3. Do I need to #include "HLSLSupport.cginc" to our shaders? 4. I'm getting compile errors when trying to use the new macro for sampling Thanks!
1. Yes. UI shaders are (mostly) independent of the render pipeline; you can use the same shader in built-in, URP, and HDRP for UGUI. 2. In DirectX9 (early 2000s), textures and samplers were kind of combined. You should prefer the new macros like SAMPLE_TEXTURE2D, but the old tex2D syntax is not going away. 3. No. If your shader has a .cg file exension, that will be included automatically. 4. You need to add a sampler variable. When using the macros, instead of having sampler2D _MainTex;, you want Texture2D _MainTex; SamplerState sampler_MainTex;.
You probably mean "if the code in your shader is inside a CGPROGRAM / ENDCG pair"? .cg is not a for shaders, but we still recognise it as a valid include extension.
Thanks for answering! I've noticed you changed your second answer after some time I will try to add the sampler var.