0
0
Unityframework~10 mins

Unlit vs lit shaders in Unity - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an unlit shader in Unity.

Unity
Shader "Custom/UnlitShader" {
  SubShader {
    Pass {
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment [1]
      ENDCG
    }
  }
}
Drag options to blanks, or click blank then click option'
Alight
Bvert
Csurf
Dfrag
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vert' instead of 'frag' for the fragment shader.
Confusing surface shaders with unlit shaders.
2fill in blank
medium

Complete the code to add lighting support in a lit shader.

Unity
Shader "Custom/LitShader" {
  SubShader {
    Tags { "RenderType" = "Opaque" }
    CGPROGRAM
    #pragma surface [1] Standard
    ENDCG
  }
}
Drag options to blanks, or click blank then click option'
Afrag
Bvert
Csurf
Dlight
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'frag' or 'vert' instead of 'surf' for surface shaders.
Omitting the lighting model like 'Standard'.
3fill in blank
hard

Fix the error in the unlit shader code by completing the missing pragma directive.

Unity
Shader "Custom/ErrorUnlit" {
  SubShader {
    Pass {
      CGPROGRAM
      #pragma vertex vert
      #pragma [1] frag
      ENDCG
    }
  }
}
Drag options to blanks, or click blank then click option'
Afragment
Bsurface
Cfrag
Dvertex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'frag' alone instead of 'fragment'.
Using 'surface' which is for surface shaders.
4fill in blank
hard

Fill both blanks to complete the surface shader function signature and return type.

Unity
struct Input {
  float2 uv_MainTex;
};

[1] surf (Input IN, inout SurfaceOutputStandard [2]) {
  [2].Albedo = float3(1, 0, 0);
}
Drag options to blanks, or click blank then click option'
Avoid
Bo
CSurfaceOutputStandard
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a struct instead of void.
Using incorrect parameter names.
5fill in blank
hard

Fill all three blanks to complete the unlit shader fragment function that outputs a fixed color.

Unity
fixed4 [1] (v2f i) : SV_Target {
  return [2];
}

struct v2f {
  float4 pos : SV_POSITION;
};

fixed4 fixedColor = fixed4([3], 1.0);
Drag options to blanks, or click blank then click option'
Afrag
Bfloat4(0.0, 1.0, 0.0, 1.0)
C0.0, 1.0, 0.0
Dvert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vert' as the fragment function name.
Returning a float4 literal without fixed4 type.
Incorrect RGB values format.