xcode 由于未编译着色器,Unity 应用程序在 iOS 上崩溃

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40283628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:30:24  来源:igfitidea点击:

Unity application crashes on iOS due to shader not compiled

iosxcodeunity3dshader

提问by Sami

I am trying to build my Unity 5.4.2f2 application for iOS. It is done with no compile errors. But when I try to run the application using Xcode 8.0, it immediately crashes and the debugger reports the following error.

我正在尝试为 iOS 构建我的 Unity 5.4.2f2 应用程序。它是在没有编译错误的情况下完成的。但是当我尝试使用 Xcode 8.0 运行应用程序时,它立即崩溃并且调试器报告以下错误。

Initialize engine version: 5.4.2f2 (b7e030c65c9b)
-------- 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_4;
    tmpvar_4 = (unity_CameraToWorld * tmpvar_3);

    highp vec4 tmpvar_5;
    tmpvar_5 = (_PreviousVP * tmpvar_4);

    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);
    tmpvar_9.xy = tmpvar_2;
    gl_FragDepthEXT = tmpvar_1.x;
    gl_FragData[0] = tmpvar_9;
}

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.

编译失败:片段评估着色器警告:0:4:不支持扩展“GL_EXT_frag_depth”错误:0:38:使用未声明的标识符“gl_FragDepthEXT”

注意:创建着色器“Hidden/Internal-MotionVectors”的内部变体失败。警告:不支持着色器:'Hidden/Internal-MotionVectors' - Pass '' 没有顶点着色器警告:不支持着色器:'Hidden/Internal-MotionVectors' - 设置为默认着色器。

Xcode 8.0 contains OPenGL 2.0.

Xcode 8.0 包含OPenGL 2.0.

At the Unity forumpeople tell us that it should be fine for Unity 5.4. But it's not working for me. On Android devices my application runs quite OK.

Unity 论坛上,人们告诉我们 Unity 5.4 应该没问题。但这对我不起作用。在 Android 设备上,我的应用程序运行得很好。

采纳答案by Sohail Bukhari

Open Unity -> Edit -> Project settings -> Graphics

打开 Unity -> 编辑 -> 项目设置 -> 图形

Then see Depth Normalsunder built-in shader setting and Choose option no Support

然后在内置着色器设置下查看深度法线并选择选项不支持

Here is Screenshot telling where to do above stuff

这是屏幕截图告诉在哪里做上面的事情

回答by Michael Sch?r

From Edit/Project Settings/Graphics can see always included shaders, see if its there

从编辑/项目设置/图形可以看到始终包含的着色器,看看它是否存在

Or if you have 3D objects in scene, disable [ ] Motion Vectors from all the mesh renderers.. You can search in hierarchy to see all of them: t:meshrendere

或者,如果场景中有 3D 对象,请禁用所有网格渲染器的 [] 运动向量。您可以在层次结构中搜索以查看所有对象:t:meshendere

For me it was the "Motion Vectors" setting (also under Edit/Project Settings/Graphics).

对我来说,它是“运动矢量”设置(也在编辑/项目设置/图形下)。

Reference: https://forum.unity3d.com/threads/hidden-shader-motionvectors.431470/

参考:https: //forum.unity3d.com/threads/hidden-shader-motionvectors.431470/

回答by NabeelKhan

this Blit shader crash is mostly because of texture compilation, IOs doesnot support dds format textures, if you are using dds textures, replace them with jpeg or any other supported extensions and it will build on IOS safely. worked for me:) after long research.

这个 Blit shader 崩溃主要是因为纹理编译,IOs 不支持 dds 格式的纹理,如果你正在使用 dds 纹理,用 jpeg 或任何其他支持的扩展替换它们,它会安全地构建在 IOS 上。对我来说有效:) 经过长时间的研究。