【问题标题】:Unity Shader Invalid Subscript 'boxMax'Unity Shader无效下标'boxMax'
【发布时间】:2017-12-04 06:06:16
【问题描述】:

我的错误是这样的:

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

使用 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 应用程序,但是当我在我的设备上打开它时它只是一个黑屏,并且在我构建它之后它显示了上面的错误。可能是什么问题呢?因为我推测上面的错误是原因。

【问题讨论】:

  • 我试过这样做 UNITY_INITIALIZE_OUTPUT(UnityGIInput, d);还是没有运气

标签: android unity3d opengl-es shader


【解决方案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

【讨论】:

  • UNITY_INITIALIZE_OUTPUT(UnityGIInput, d)。 UnityGIInput d 之后;线为我工作。谢谢。
猜你喜欢
  • 2021-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 2021-10-07
相关资源
最近更新 更多