Complete the code to declare an unlit shader in Unity.
Shader "Custom/UnlitShader" { SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment [1] ENDCG } } }
The fragment shader function is declared with #pragma fragment frag to handle pixel colors in an unlit shader.
Complete the code to add lighting support in a lit shader.
Shader "Custom/LitShader" { SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface [1] Standard ENDCG } }
Surface shaders use #pragma surface surf Standard to enable lighting and standard shading models.
Fix the error in the unlit shader code by completing the missing pragma directive.
Shader "Custom/ErrorUnlit" { SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma [1] frag ENDCG } } }
The correct pragma directive for the fragment shader is #pragma fragment frag. Using 'fragment' specifies the fragment shader function.
Fill both blanks to complete the surface shader function signature and return type.
struct Input {
float2 uv_MainTex;
};
[1] surf (Input IN, inout SurfaceOutputStandard [2]) {
[2].Albedo = float3(1, 0, 0);
}The surface shader function returns void and uses an inout parameter named o to modify the surface output.
Fill all three blanks to complete the unlit shader fragment function that outputs a fixed color.
fixed4 [1] (v2f i) : SV_Target { return [2]; } struct v2f { float4 pos : SV_POSITION; }; fixed4 fixedColor = fixed4([3], 1.0);
The fragment function is named 'frag', returns a fixed4 color, and the fixedColor uses RGB values '0.0, 1.0, 0.0' for green.