【问题标题】:Altering materials shows as pink on Samsung TV改变材料在三星电视上显示为粉红色
【发布时间】:2016-09-22 15:53:26
【问题描述】:

我正在使用 Unitys build > Samsung TV 为三星电视制作应用程序。

我有一堆原始框,其中我已将材质 mainTexture 更改为图集,并将网格过滤器 uv 更改为 PackTextures 方法中的给定 uv。

            Texture2D[] allCubeTextures = new Texture2D[] { app.GetComponentInChildren<Image>().mainTexture as Texture2D, Resources.Load<Texture2D>("Black"), Resources.Load<Texture2D>("Black"), Resources.Load<Texture2D>("Black"), Resources.Load<Texture2D>("Black"), Resources.Load<Texture2D>("Black") };
            Texture2D textureAtlas = new Texture2D(2, 2);
            Rect[] atlasUvs = textureAtlas.PackTextures(allCubeTextures, 200);
            icon.GetComponent<Renderer>().material.mainTexture = textureAtlas;
            Vector2[] uv = new Vector2[6 * 4];
            for (int i = 0; i < atlasUvs.Length; i++)
            {
                int j = i * 4;
                uv[j] = new Vector2(atlasUvs[i].xMin, atlasUvs[i].yMin);
                uv[j + 1] = new Vector2(atlasUvs[i].xMax, atlasUvs[i].yMin);
                uv[j + 2] = new Vector2(atlasUvs[i].xMin, atlasUvs[i].yMax);
                uv[j + 3] = new Vector2(atlasUvs[i].xMax, atlasUvs[i].yMax);
            }
            Mesh mesh = icon.GetComponent<MeshFilter>().mesh;
            mesh.uv = uv;

在编辑器中看起来一切都很好,但是,每当我在三星电视上测试时,这些盒子都是粉红色的(好像它们是坏掉的着色器)。

在将 mainTexture 编辑为图集纹理之前,我使用了统一标准 uv。这行得通,但我的纹理是四面八方的,而不是我的图集现在如何处理它。这就是为什么我认为它可能与此有关。

为了解决这个错误,我还尝试了一堆不同的着色器,但没有不同的结果。

只是三星电视不支持我的纹理的这种实现吗?

三星电视日志:

Game_Main:209] GPlayer PFM Ver : (1001) 
Failed to create random directory /tmp/pulseaudio/pulse-XswsA4ySxtTi: Permission denied
Mono path[0] = '/opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed'
Mono config path = '/opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed'
using 32 bit
using 24 bit depth
Renderer: 
Vendor:   ARM
Version:  OpenGL ES 2.0
GLES:     2
GL_OES_texture_npot GL_OES_vertex_array_object GL_OES_compressed_ETC1_RGB8_texture GL_EXT_compressed_ETC1_RGB8_sub_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_depth24 GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_OES_vertex_half_float GL_EXT_blend_minmax GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_rgb8_rgba8 GL_EXT_multisampled_render_to_texture GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_ARM_mali_program_binary GL_EXT_shader_texture_lod GL_EXT_robustness GL_OES_depth_texture_cube_map GL_KHR_debug GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_OES_mapbuffer
OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context level  <OpenGL ES 2.0> ; Context handle 1073741825
Initialize engine version: 5.4.1f1 (649f48bbbf0f)
Failed to create random directory /tmp/pulseaudio/pulse-Ivi10nSJCUJP: Permission denied
Failed to create random directory /tmp/pulseaudio/pulse-YonkWqDHH005: Permission denied
Not enough permissions to set priority (must be root)Begin MonoManager ReloadAssembly
Platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/UnityEngine.dll (this message is harmless)
Loading /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/UnityEngine.dll into Unity Child Domain
Non platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/Assembly-CSharp.dll (this message is harmless)
Loading /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/Assembly-CSharp.dll into Unity Child Domain
Non platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/UnityEngine.UI.dll (this message is harmless)
Loading /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/UnityEngine.UI.dll into Unity Child Domain
Non platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/UnityEngine.Networking.dll (this message is harmless)
Loading /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/User/UnityEngine.Networking.dll into Unity Child Domain
- Completed reload, in  0.133 seconds
Platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/System.Core.dll (this message is harmless)
Platform assembly: /opt/storage/usb/sda1/f0caae903700866889117406a674369e6e82bef3/resources/Data/Managed/System.dll (this message is harmless)
-------- Shader compilation failed
#version 100
#extension GL_EXT_frag_depth : enable
precision mediump 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
0:4: P0003: Extension 'GL_EXT_frag_depth' not supported
0:6: P0004: High precision not supported, instead compiling high precision as medium precision
0:38: L0002: Undeclared variable '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.
UnloadTime: 4.557000 ms
Unloading 4 Unused Serialized files (Serialized files now loaded: 0)

Unloading 8 unused Assets to reduce memory usage. Loaded Objects now: 844.
Total: 4.570000 ms (FindLiveObjects: 0.397000 ms CreateObjectMapping: 0.061000 ms MarkObjects: 3.410000 ms  DeleteObjects: 0.691000 ms)

Unloading 2 Unused Serialized files (Serialized files now loaded: 0)

Unloading 94 unused Assets to reduce memory usage. Loaded Objects now: 1056.
Total: 16.380001 ms (FindLiveObjects: 0.444000 ms CreateObjectMapping: 0.075000 ms MarkObjects: 3.665000 ms  DeleteObjects: 12.190001 ms)

[UnityLauncher] Stop Game

编辑: 在做了一些进一步的挖掘之后,我认为我的问题与: Textures loads in editor but not in standalone (appears pink) 我不太明白解决方案。选择预加载着色器时,我别无选择。另外,我使用的是标准着色器,所以我认为这不是问题。

编辑 2: 好的,经过更多研究后,我发现了这篇文章:http://answers.unity3d.com/questions/939160/getting-pink-textures-in-build.html 看来我必须将我的着色器(Unlit/Texture)添加到始终包含的着色器中。但是,这只会将框更改为白色而不是粉红色。正如 Legacy/Diffuse 所做的那样,它也在始终包含的着色器中。

【问题讨论】:

  • 三星是哪一年制造的,型号是多少?
  • 在 15 和 16 型号上测试。

标签: c# unity3d unity5 samsung-smart-tv


【解决方案1】:

我注意到三星电视日志中有一行:-------- Shader compilation failed 您的着色器编译失败,所以粉红色的东西是预期的行为。

着色器可以在设备上编译和运行良好,但在其他设备上失败。这很正常。如果您使用的是内置标准着色器,请向 Unit 报告错误,否则请在支持 SamsungTV 设备的着色器中包含子着色器。

这部分也要注意:

fragment evaluation shader
0:4: P0003: Extension 'GL_EXT_frag_depth' not supported
0:6: P0004: High precision not supported, instead compiling high precision as medium precision
0:38: L0002: Undeclared variable '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.

据我所知,您的着色器使用了一个名为 GL_EXT_frag_depth 的不受支持的库,这会导致该类型的变量 gl_FragDepthEXT 未声明。

【讨论】:

  • 我尝试过 Unlit/Textures、Legacy/Diffuse、Standard、Mobile/Unlit 和 Mobile Diffuse。全粉红色,但旧版/漫反射。那个是白色的。我看到了你所看到的,并使用不同的着色器进行了测试,如 OP 中所写。没有不同的结果。这就是为什么我的结论是它一定与我的纹理图集有关。我只是看不到什么。
【解决方案2】:

好的,所以我找到了解决方案。

正如编辑 1 中的链接中所写,我必须将着色器都包含在“编辑”>“项目设置”>“图形”下的“始终包含的着色器”中。 然后我必须将 ShaderVariant 保存到我的资产文件夹,并将该变体添加到“Shader Preloading”中。

【讨论】:

  • 不错。像这样的问题很难找到解决办法。恭喜!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-24
  • 2018-05-25
  • 1970-01-01
  • 2022-07-29
  • 2022-11-06
  • 1970-01-01
相关资源
最近更新 更多