NearPlaneFade Script no longer works on device
I'm not sure if this is something new to Unity 5.5 or if it has been around for longer than that. I am currently running Unity 5.5.0p1. When running in the editor, the script behaves as expected and holograms rendered with a with supported shader fade out within the correct distance. When running on the device, however, the NearPlaneFade script appears to have no effect and the holograms no longer fade as you approach them.
As a side observation, it looks like the StandardFast shader doesn't support near plane fading at all. I imagine this is because the StandardFast shader mostly just leverages the existing UnityStandardCoreForward implementation
I think this has something to do with this line:
#pragma shader_feature _NEAR_PLANE_FADE_ON
The Unity documentation says this about shader_feature:
#pragma shader_feature is very similar to #pragma multi_compile, the only difference is that unused variants of shader_feature shaders will not be included into game build. So shader_feature makes most sense for keywords that will be set on the materials, while multi_compile for keywords that will be set from code globally.
So it sounds like given the way _NEAR_PLANE_FADE_ON is set dynamically via code, and not dependent on material settings, a better approach would be to use:
#pragma multi_compile _ _NEAR_PLANE_FADE_ON
This seems like it fixes the problem, but being a relative novice in Unity, are there any downsides to this change that I might not be aware of?
@thebanjomatic this is now closed correct?
Yes, thanks!
This issue seems to have reappeared. Unity 5.5.2p3. Works fine in the editor with expected fade out. However, on the device and in running in Unity with Holographic Emulation, there is no effect. Have checked the shader used (Vertex Lit Configurable) has the below already in the code.
#pragma multi_compile __ _NEAR_PLANE_FADE_ON
@reddo123 I'll try and take a look at reproducing this soon. Does it only happen with Vertex Lit Configurable, or are the other shaders effected also?
I have been using Unity 5.6 for a while now and built something earlier this week using NearPlaneFade with the Fast Configurable Shader and everything worked fine for me in that configuration. Do you think this is something that is 5.5.2 specific?
@thebanjomatic, thanks for the relook. Discovered the Fade Distance End parameters weren't relative with the Near Clipping Plane setting and obviously cancelled out the effect. That solved the issue.