Use of undeclared identifier 'gl_FragDepthEXT'

Hi, I’m new in unity. I’m working on unity 2017.2.0f3 personal edition. My project is running properly on Android. But getting error in “ios” build.
I tried solutions given at https://forum.unity.com/threads/hidden-shader-motionvectors.431470/ and xcode - Unity application crashes on iOS due to shader not compiled - Stack Overflow

But it is not worked.

Error log is as follows:-

2017-11-06 18:56:39.390 racing[319:65404] → registered mono modules 0x14f75b0
→ applicationDidFinishLaunching()
Mono path[0] = ‘/var/mobile/Containers/Bundle/Application/B9C1D955-EFFC-4995-AF6D-A27819926161/racing.app/Data/Managed’
Mono config path = ‘/var/mobile/Containers/Bundle/Application/B9C1D955-EFFC-4995-AF6D-A27819926161/racing.app/Data/Managed’

Multi-casting “[IP] 192.168.1.3 [Port] 55000 [Flags] 2 [Guid] 2438281812 [EditorId] 1171095358 [Version] 1048832 [Id] iPhonePlayeriPad):56000 [Debug] 0” to [225.0.0.222:54997]…
Started listening to [0.0.0.0:55000]
PlayerConnection already initialized - listening to [0.0.0.0:55000]
Player data archive not found at /racing.app/Data/data.unity3d, using local filesystem
2017-11-06 18:56:40.434 racing[319:65404] Metal GPU Frame Capture Enabled
2017-11-06 18:56:40.435 racing[319:65404] Metal API Validation Disabled
→ applicationDidBecomeActive()
Renderer: PowerVR SGX 543
Vendor: Imagination Technologies
Version: OpenGL ES 2.0 IMGSGX543-124.1
GLES: 2
GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_read_format GL_IMG_texture_comp
ression_pvrtc
OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context level ; Context handle 359299568
Initialize engine version: 2017.2.0f3 (46dda1414e51)
Begin MonoManager ReloadAssembly

  • Completed reload, in 0.292 seconds
    -------- Shader compilation failed
    #version 100
    #extension GL_EXT_frag_depth : enable
    precision highp float;
    uniform highp vec4 _ProjectionParams;
    uniform highp vec4 _ZBufferParams;
    uniform highp mat4 unity_CameraToWorld;
    uniform highp mat4 _NonJitteredVP;
    uniform highp mat4 _PreviousVP;
    uniform highp sampler2D _CameraDepthTexture;
    varying highp vec2 xlv_TEXCOORD0;
    varying highp vec3 xlv_TEXCOORD1;
    void main ()
    {
    highp vec4 tmpvar_1;
    tmpvar_1 = texture2D (_CameraDepthTexture, xlv_TEXCOORD0);
    mediump vec2 tmpvar_2;
    highp vec4 tmpvar_3;
    tmpvar_3.w = 1.0;
    tmpvar_3.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * (1.0/((
    (_ZBufferParams.x * tmpvar_1.x)
    • _ZBufferParams.y))));
      highp vec4 tmpvar_6;
      tmpvar_6 = (_NonJitteredVP * tmpvar_4);
      highp vec2 tmpvar_7;
      tmpvar_7 = (((tmpvar_5.xy / tmpvar_5.w) + 1.0) / 2.0);
      highp vec2 tmpvar_8;
      tmpvar_8 = (((tmpvar_6.xy / tmpvar_6.w) + 1.0) / 2.0);
      tmpvar_2 = (tmpvar_8 - tmpvar_7);
      mediump vec4 tmpvar_9;
      tmpvar_9.zw = vec2(0.0, 1.0);

}
-------- failed compiling:
fragment evaluation shader
WARNING: 0:4: extension ‘GL_EXT_frag_depth’ is not supported
ERROR: 0:38: Use of undeclared identifier ‘gl_FragDepthEXT’

Note: Creation of internal variant of shader ‘Hidden/Internal-MotionVectors’ failed.
WARNING: Shader Unsupported: ‘Hidden/Internal-MotionVectors’ - Pass ‘’ has no vertex shader
WARNING: Shader Unsupported: ‘Hidden/Internal-MotionVectors’ - Setting to default shader.
-------- Shader compilation failed
#version 100
#extension GL_EXT_frag_depth : enable
precision highp float;
uniform sampler2D _MainTex;
uniform highp sampler2D _DepthTex;
uniform highp vec4 _Color;
varying highp vec2 xlv_TEXCOORD0;
void main ()
{
lowp vec4 tmpvar_1;
tmpvar_1 = (texture2D (_MainTex, xlv_TEXCOORD0) * _Color);
gl_FragDepthEXT = texture2D (_DepthTex, xlv_TEXCOORD0).x;
gl_FragData[0] = tmpvar_1;
}
-------- failed compiling:
fragment evaluation shader
WARNING: 0:4: extension ‘GL_EXT_frag_depth’ is not supported
ERROR: 0:14: Use of undeclared identifier ‘gl_FragDepthEXT’

Note: Creation of internal variant of shader ‘Hidden/BlitCopyWithDepth’ failed.
WARNING: Shader Unsupported: ‘Hidden/BlitCopyWithDepth’ - Pass ‘’ has no vertex shader
WARNING: Shader Unsupported: ‘Hidden/BlitCopyWithDepth’ - Setting to default shader.
WARNING: Shader Unsupported: ‘Hidden/VR/BlitTexArraySlice’ - Pass ‘’ has no vertex shader
WARNING: Shader Unsupported: ‘Hidden/VR/BlitTexArraySlice’ - Setting to default shader.
The referenced script on this Behaviour (Game Object ‘Main Camera’) is missing!

(Filename: /Users/builduser/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp Line: 1753)

Setting up 1 worker threads for Enlighten.
Thread → id: 40081000 → priority: 1
UnloadTime: 11.044541 ms
AddComponent asking for “AudioSource” which is not a Unity engine type.
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type)
UnityEngine.GameObject:AddComponent()
UiHandle:Start()

[/Users/builduser/buildslave/unity/build/Runtime/Export/GameObjectExport.cpp line 71]
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/GameObjectExport.cpp Line: 71)

AddComponent asking for “AudioSource” which is not a Unity engine type.
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type)
UnityEngine.GameObject:AddComponent()
UiHandle:Start()

[/Users/builduser/buildslave/unity/build/Runtime/Export/GameObjectExport.cpp line 71]
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/GameObjectExport.cpp Line: 71)

(lldb)

Please help me solving this issue.

Thanks.

Sorry for my English.

Will the landlord solve this problem? I recently encountered the same problem. If it is solved, can you tell me how to do it? ,请问楼主解决这个问题了吗?如果解决了可以告诉我一下方法不?
Will the landlord solve this problem? I recently encountered the same problem. If it is solved, can you tell me how to do it?

Well, the answer is simple: The hardware you’re running your game on does not support reading back the fragment depth as you can read in the log:

extension 'GL_EXT_frag_depth' is not supported 

So this is most likely a hardware or driver issue.

For a possible workaround see this question