Is there a list of Shader input struct naming conventions?

Warning: I don’t know much about shaders, so please bear with me.

I was trying to go through the default Unity shader, and encountered the following code:

struct Input
{
     float2 uv_MainTex;
};

From a different tutorial I gathered that this is the uv coordinate of the texture MainTex, and it is this way because it’s called uv_MainTex (so calling it something else wouldn’t work). I would like to know the full list of special naming conventions that are supported in Unity (or is this an HLSL thing).

Is there a resource that has a reference to all of these naming conventions? (Also, I’m not sure if this has a special name, if it does I’d also like to know that, might have helped searching for this)

Well, this can not be answered that simple. The only convention that is at play here in your example is that the corresponding uv coordinates of a certain texture sampler is simply named uvXXXXX where the XXXXX is the texture sampler name. You can name those however you like. This is explained over here in the shader lab documentation.

Though you also have to distinguish between Unity’s “surface shaders” which are a more high level way of writing shaders and Unity is actually producing the corresponding vectex and fragment shaders for you.

Another general HLSL thing you may need to understand are the shader sematics. Every input or output value needs to have some kind of sematic meaning. If not given explicitly they get them implicitly. There are only a certain number of UV channels, position channels, color channels you can have at the same time. This greatly differs depending on the hardware support.

Next are the actual built-in variables given by Unity. Those are actually static uniform variables.

Another great source is the examples page which shows several different examples.

There has been a couple of questions about a full list of shader property names. However those completely depend on the actual shader… You can use the GetTexturePropertyNames method, however it only lists the “exposed” properties and not necessarily all uniform variables a shader may use.

As for the input structure, here’s a book that references an old documentaion page which lists some additional input names.

This list exists here in the Unity docs, under the Surface Shader input structure heading.