OpenGLES3 fails to compile shaders Hidden/Post FX/ for Android in Unity 2018.2

I’m trying out Unity 2018.2 with the LW VR preset setup for my Gear VR (2017) on my Samsung Galaxy S9+ (Android Oreo 8.0.0). But when I try to build for Android it fails to compile some shaders.

I get messages like this:

Shader error in 'Hidden/Post FX/Fog': undeclared identifier 'sampler_CameraDepthTexture' at line 63 (on gles3)

Compiling Vertex program with STEREO_MULTIVIEW_ON

I also get similar messages for:

Shader error in 'Hidden/Post FX/Screen Space Reflection': undeclared identifier 'sampler_CameraDepthTexture' at line 129 (on gles3)

Shader error in 'Hidden/Post FX/Motion Blur': undeclared identifier 'sampler_CameraDepthTexture' at Assets/PostProcessing/Resources/Shaders/MotionBlur.cginc(90) (on gles3)

Shader error in 'Hidden/Post FX/Uber Shader': undeclared identifier 'sampler_CameraDepthTexture' at line 190 (on gles3)

Shader error in 'Hidden/Post FX/Depth Of Field': undeclared identifier 'sampler_CameraDepthTexture' at Assets/PostProcessing/Resources/Shaders/DepthOfField.cginc(81) (on gles3)

Shader error in 'Hidden/Post FX/Ambient Occlusion': undeclared identifier 'sampler_CameraDepthTexture' at Assets/PostProcessing/Resources/Shaders/AmbientOcclusion.cginc(106) (on gles3)

Shader error in 'Hidden/Post FX/Temporal Anti-aliasing': undeclared identifier 'sampler_CameraDepthTexture' at Assets/PostProcessing/Resources/Shaders/TAA.cginc(70) (on gles3)

It also outputs this:

UnityEditor.BuildPlayerWindow+BuildMethodException: 8 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0021f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:187 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:94 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

If I remove OpenGLES3 and only build using Vulkan the shaders compiles but then the per eye rendering and rotation tracking does not work, but that’s another issue.

Any ideas of how to fix these shader errors?

I found an answer that worked for me here Unity Issue Tracker - [XR][Android] Image effects are not rendering properly with single-pass

As Arkade says, to fix any shader with this problem, swap the declaration of the sampler from:

uniform sampler2D_float _CameraDepthTexture;

I had this error too. I just searched for post processing on the project manager (where you view your assets) and then deleted the post processing folder.

I think I must have imported an asset pack that contained some post processing scripts. I don’t think these are needed for VR?

Anyway I deleted all the post processing stuff and i managed to build my apk without any errors.