Complete the code to declare a simple shader with a name.
Shader "[1]" { SubShader { Pass { } } }
The shader name must be a string with a path-like format, such as "Custom/Basic".
Complete the code to define a color property in the Properties block.
Properties {
_Color ("Main Color", [1]) = (1,1,1,1)
}The property type for colors in Unity shaders is Color.
Fix the error in the fragment shader function declaration.
fixed4 [1](v2f i) : SV_Target { return _Color; }
The fragment shader function is commonly named frag in Unity shaders.
Fill both blanks to sample the main texture color in the fragment shader.
sampler2D _MainTex;
fixed4 frag(v2f i) : SV_Target {
fixed4 col = tex2D([1], [2]);
return col * _Color;
}Use _MainTex as the texture sampler and i.uv as the UV coordinates to sample the texture color.
Fill all three blanks to declare a vertex input struct with position and UV, and pass UV to fragment shader.
struct appdata {
float4 [1] : POSITION;
float2 [2] : TEXCOORD0;
};
struct v2f {
float2 [3] : TEXCOORD0;
float4 vertex : SV_POSITION;
};The vertex input struct uses vertex for position and uv for texture coordinates. The v2f struct passes uv to the fragment shader.