PC端正常显示打包,Android平台打包显示有问题。
1.shader报错
报错内容:Unity Shader (Shader error in ‘xxx‘: invalid subscript ‘boxMax‘)
解决办法:
将以下第一段代码替换成第二段:
UnityGIInput d;
? ? ? ? ? ? ? ? d.light = light;
? ? ? ? ? ? ? ? d.worldPos = i.posWorld.xyz;
? ? ? ? ? ? ? ? d.worldViewDir = viewDirection;
? ? ? ? ? ? ? ? d.atten = attenuation;
? ? ? ? ? ? ? ? #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
? ? ? ? ? ? ? ? ? ? d.ambient = 0;
? ? ? ? ? ? ? ? ? ? d.lightmapUV = i.ambientOrLightmapUV;
? ? ? ? ? ? ? ? #else
? ? ? ? ? ? ? ? ? ? d.ambient = i.ambientOrLightmapUV;
? ? ? ? ? ? ? ? #endif
? ? ? ? ? ? ? ? d.boxMax[0] = unity_SpecCube0_BoxMax;
? ? ? ? ? ? ? ? d.boxMin[0] = unity_SpecCube0_BoxMin;
? ? ? ? ? ? ? ? d.probePosition[0] = unity_SpecCube0_ProbePosition;
? ? ? ? ? ? ? ? d.probeHDR[0] = unity_SpecCube0_HDR;
? ? ? ? ? ? ? ? d.boxMax[1] = unity_SpecCube1_BoxMax;
? ? ? ? ? ? ? ? d.boxMin[1] = unity_SpecCube1_BoxMin;
? ? ? ? ? ? ? ? d.probePosition[1] = unity_SpecCube1_ProbePosition;
? ? ? ? ? ? ? ? d.probeHDR[1] = unity_SpecCube1_HDR;
UnityGIInput d;
d.light = light;
d.worldPos = i.posWorld;
d.worldViewDir = viewDirection;
d.atten = attenuation;
#if (LIGHTMAP_ON) || (DYNAMICLIGHTMAP_ON)
d.ambient = 0;
d.lightmapUV = i.ambientOrLightmapUV;
#else
d.ambient = i.ambientOrLightmapUV.rgb;
d.lightmapUV = 0;
#endif
d.probeHDR[0] = unity_SpecCube0_HDR;
d.probeHDR[1] = unity_SpecCube1_HDR;
#if (UNITY_SPECCUBE_BLENDING) || (UNITY_SPECCUBE_BOX_PROJECTION)
d.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
#endif
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
d.boxMax[0] = unity_SpecCube0_BoxMax;
d.probePosition[0] = unity_SpecCube0_ProbePosition;
d.boxMax[1] = unity_SpecCube1_BoxMax;
d.boxMin[1] = unity_SpecCube1_BoxMin;
d.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
报错问题解决(亲测有效)
2.shader在Android平台打包后显示黑色
解决办法:
找到? #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2内容,注释即可
?打包到pico中测试有效
3.unity自带shader位置
?
|