Lighting and shadows
Lighting is an essential element in our scenes, but as we have already seen, it takes some work to get it right. In this section, we will revisit lighting and also tackle adding shadows. Adding shadows to our objects will make them look like they are really there. We will start with adding shadows, so open up Unity and follow along:
- Create a new shader called
UnlitShadowReceiver
in theAssets/ARCoreDesign/Materials/Shaders
folder. - Double-click on the new shader to open it in your code editor.
- Select all the autogenerated code and delete it. Then, add the following code:
Shader "ARCoreDesign/UnlitShadowReceiver" { Properties { _Color("Main Color", Color) = (1,1,1,1) _MainTex("Base (RGB)", 2D) = "white" {} _Cutoff("Cutout", Range(0,1)) = 0.5 } SubShader { Pass { Alphatest Greater[_Cutoff] SetTexture[_MainTex] } Pass { Blend DstColor Zero Tags{ "LightMode" = "ForwardBase" } CGPROGRAM #pragma vertex vert #pragma fragment frag ...