- Home /
[BUG] Can't use postprocessing with single-pass stereo rendering enabled (5.6, GearVR)
Whenever building any application for GearVR (Presumably any Android VR application) it is impossible to use any post processing. I have tried it with Unity's legacy image effects, other plugins like AmplifyColor, and the new PostProcessing stack. All of these things claim to have been updated to support single-pass stereo rendering.
If I build with multi-pass, everything compiles fine and works fine on the app. If I build with single-pass, the screen is white or mostly white, depending on the effect. With a noise effect I can see extremely large pixels bouncing around, so something is running. Of note is the fact that many of the unity default and included shaders throw an error when single-pass is enabled and compiled.
Shader error in 'Hidden/Post FX/Uber Shader': undeclared identifier 'sampler_CameraDepthTexture' at line 191 (on gles3)
Compiling Vertex program with STEREO_MULTIVIEW_ON DEPTH_OF_FIELD_COC_VIEW
Platform defines: UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 SHADER_API_MOBILE UNITY_HARDWARE_TIER2 UNITY_COLORSPACE_GAMMA
This error shows up in every shader, included or custom, that runs SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv); This includes the built-in shaders, which I cannot modify. I have checked every shader that I can, and the variables are indeed declared; not to mention that they work fine when compiled in multi-pass. It seems like single-pass stereo rendering is revoking access to the depth texture, which causes any post processing to render directly on top of the camera, causing the white or broken view.
Reproduction steps (GearVR):
Make any unity project
Import any post-processing effects. (Eg. The legacy image effects or the new PostProcessing stack)
Add any effect(s) to the camera.
Build with multi-pass rendering, observe that it works fine.
Build with single-pass stereo rendering, test the app on GearVR and see the problems. Also note the new errors in the shaders which appear in the unity console output. Those do not happen in multi-pass.
Note: It seems unity was well aware of this issue already, and have marked it as lower priority. There is a workaround available, which is to just not use it. You can track the issue here, hopefully with enough pressure they will speed up the fixing of this issue. It's definitely a development problem.
Answer by Arkade · Jan 31, 2018 at 08:09 PM
To fix any shader with the "`undeclared identifier 'sampler_CameraDepthTexture'`" error, swap the declaration of the sampler from:
uniform sampler2D_float _CameraDepthTexture;
to
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
Caveat: I've not checked that this makes post FX work with single-pass VR but since I came across this question while investigating that error, I thought I'd post that part of the answer here. HTH :-)
hi Arkade
did you fixed that problem. i change sampler2D to sampler2D_float but not solve that.
Answer by EpicCubeGroup · Jun 18, 2017 at 10:49 AM
Hi, I've tried to run Post Processing Stack on my GearVR app, but no post processing is done (multi-pass rendering set). Why? Any particular setting is needed?