URP

TEXTURE2D_ARGS and TEXTURE2D_PARAS help passing texture and sampler to methods.

TEXTURE2D(_AlbedoMap);
TEXTURE2D_SAMPLER(sampler_AlbedoMap);

half4 SampleAlbedo(float2 uv, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
{
	return SAMPLE_TEXTURE2D(albedoMap, sampler_albedoMap, uv);
}

// to call SampleAlbedo, we have:
half4 albedoAlpha = SampleAlbedo(uv, TEXTURE2D_ARGS(_Albedo, sampler_Albedo));

https://catlikecoding.com/unity/tutorials/scriptable-render-pipeline/global-illumination/

Vertex Compression vs. Mesh Compression

Vertex Compression is in the Player Settings. It works on all the mesh files. It will compress vertex data from 32-bit to 16-bit to help the game’s performance by reducing the mesh data size in memory and file size. However, it does have some restriction:

  • turn off Read/Write Enabled
  • no Skinned Mesh
  • target platform must support half.
  • turn off Mesh Compression

Texcoord0 and Texcoord1 should not be half, because they usually function as uv for sampling texture. When the texture’s size is too big, half uv cannot give desired sampling result (https://forum.unity.com/threads/why-does-unity-recommend-us-to-use-float-type-for-texture-coordinates-in-the-shader.732920/).

Mesh Compression is in the mesh’s settings. It works on individual meshes. Compressing the mesh data on the disk reduces the file size. It potentially adds more loading time and increases temporary memory usage. Once the mesh is in the memory, Unity will decompress the data. It does not affect the performance but only reduce the build size.

Shader

pow(x, y)

According to bgolus (https://forum.unity.com/threads/expensiveness-of-high-powers.788171/) and Lagarde (https://forum.unity.com/threads/expensiveness-of-high-powers.788171/) and actual practice, pow(x, y) is actually exp2(log2(x), y). It introduces a potential problem, that is log2(x) might return the negative infinity. It’s safer to ensure x would never be 0. For specular power, Lagarde’s optimization eliminated this problem.