"// Light sources\n"
"uniform vec4 occLightAmbient; //!< Cumulative ambient color\n"
"#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
+ "#if (THE_MAX_LIGHTS > 1)\n"
+ " #define occLight_Index(theId) theId\n"
+ "#else\n"
+ " #define occLight_Index(theId) 0\n"
+ "#endif\n"
"uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n"
"\n"
"//! Type of light source, int (see OccLightType enum).\n"
- "#define occLight_Type(theId) occLightSourcesTypes[theId]\n"
+ "#define occLight_Type(theId) occLightSourcesTypes[occLight_Index(theId)]\n"
"\n"
"//! Specular intensity (equals to diffuse), vec3.\n"
- "#define occLight_Specular(theId) occLightSources[theId * 4 + 0].rgb\n"
+ "#define occLight_Specular(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n"
"\n"
"//! Intensity of light source (>= 0), float.\n"
- "#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a\n"
+ "#define occLight_Intensity(theId) occLightSources[occLight_Index(theId) * 4 + 0].a\n"
"\n"
"//! Is light a headlight, bool? DEPRECATED method.\n"
"#define occLight_IsHeadlight(theId) false\n"
"\n"
"//! Position of specified light source or direction of directional light source, vec3.\n"
- "#define occLight_Position(theId) occLightSources[theId * 4 + 1].xyz\n"
+ "#define occLight_Position(theId) occLightSources[occLight_Index(theId) * 4 + 1].xyz\n"
"\n"
"//! Direction of specified spot light source, vec3.\n"
- "#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2].xyz\n"
+ "#define occLight_SpotDirection(theId) occLightSources[occLight_Index(theId) * 4 + 2].xyz\n"
"\n"
"//! Range on which point light source (positional or spot) can affect (>= 0), float.\n"
- "#define occLight_Range(theId) occLightSources[theId * 4 + 2].w\n"
+ "#define occLight_Range(theId) occLightSources[occLight_Index(theId) * 4 + 2].w\n"
"\n"
"//! Maximum spread angle of the spot light (in radians), float.\n"
- "#define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z\n"
+ "#define occLight_SpotCutOff(theId) occLightSources[occLight_Index(theId) * 4 + 3].z\n"
"\n"
"//! Attenuation of the spot light intensity (from 0 to 1), float.\n"
- "#define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w\n"
+ "#define occLight_SpotExponent(theId) occLightSources[occLight_Index(theId) * 4 + 3].w\n"
"\n"
"#if !defined(THE_IS_PBR)\n"
"//! Diffuse intensity (equals to Specular), vec3.\n"
- "#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0].rgb\n"
+ "#define occLight_Diffuse(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n"
"\n"
"//! Const attenuation factor of positional light source, float.\n"
- "#define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x\n"
+ "#define occLight_ConstAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].x\n"
"\n"
"//! Linear attenuation factor of positional light source, float.\n"
- "#define occLight_LinearAttenuation(theId) occLightSources[theId * 4 + 3].y\n"
+ "#define occLight_LinearAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].y\n"
"#endif\n"
"#endif\n"
"\n"