- Home /
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
Platform defines: UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_NO_CUBEMAP_ARRAY UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 SHADER_API_MOBILE UNITY_HARDWARE_TIER2 UNITY_LIGHTMAP_DLDR_ENCODING
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?
not really cause they're unity internal shaders. I'd file that as a bug report.
I've filed a bug report, let's hope they can fix it soon! :)
Answer by mckinnonCT · Oct 05, 2018 at 05:14 PM
I found an answer that worked for me here https://issuetracker.unity3d.com/issues/gearvr-singlepassstereo-image-effects-are-not-rendering-properly
As Arkade says, to fix any shader with this problem, swap the declaration of the sampler from:
touniform sampler2D_float _CameraDepthTexture;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
Thanks, this appears to have worked for my situation with the Oculus Go & Unity 2018.3.6f1
How did u excatly solve this ?can u please explain in detail , in my case i couldn't first code snippet you were mentioning
So, in my case, these shader errors are found in the Post Processing shader pack. So look in Assets > Post Processing > Resources > Shaders. I had several scripts with this error, like AmbientOcclusion.cginc, Fog.shader, and $$anonymous$$otionBlur.cginc for example. Just open up whichever scripts are causing errors (or just search for sampler2D_float), look for a line with "sampler2D_float _CameraDepthTexture;" and replace those lines with UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
Answer by nonstop99 · Mar 18, 2021 at 03:47 PM
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.
Your answer
Follow this Question
Related Questions
No acceptable conversion when converting cg shader to glsl 0 Answers
Add transparency to sprite shader with cast shadows and receive shadows and lighting 2 Answers
Shader For cut hole and alpha blend 1 Answer
Is it possible to pair an animated normal map image sequence to a diffuse sprite sequence? 1 Answer