Unity Shader无效下标'boxMax'

时间:2017-12-04 06:06:17

标签: android unity3d opengl-es shader

我的错误是:

  

'Volund / Standard Character(Specular)'中的着色器错误:Assets / Features / Shared / Volund_UnityStandardCore.cginc(261)(在d3d11上)的无效下标'boxMax'

     

使用DIRECTIONAL _NORMALMAP _SPECGLOSSMAP

编译Vertex程序      

平台定义:UNITY_NO_DXT5nm UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDf2 SHADER_API_DESKTOP UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA

我粘贴了上面的完整错误,所以请看一下。

以下是我的着色器代码:

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;

现在我把它改成了

#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
    d.boxMin[0] = unity_SpecCube0_BoxMin;
    d.boxMin[1] = unity_SpecCube1_BoxMin;
#endif


#if UNITY_SPECCUBE_BOX_PROJECTION
    d.boxMax[0] = unity_SpecCube0_BoxMax;
    d.boxMax[1] = unity_SpecCube1_BoxMax;
    d.probePosition[0] = unity_SpecCube0_ProbePosition;
    d.probePosition[1] = unity_SpecCube1_ProbePosition;
  

现在出错:变量d未经完全初始化使用。

我的问题是我成功将我的.exe应用程序转换为.apk应用程序,但是当我在我的设备上打开它时,它只是一个黑屏,它在我构建它之后显示上面的错误。可能是什么问题呢?因为我推测上面的错误是原因。

1 个答案:

答案 0 :(得分:1)

我只想分享我在这里所做的事情

UnityGIInput d;
UNITY_INITIALIZE_OUTPUT(UnityGIInput, d);
d.light = light;
d.worldPos = posWorld;
d.worldViewDir = -eyeVec;
d.atten = atten;
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
    d.ambient = 0;
    d.lightmapUV = i_ambientOrLightmapUV;
#else
    d.ambient = i_ambientOrLightmapUV.rgb;
    d.lightmapUV = 0;
#endif

#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
    d.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
#endif

#if 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