以下代码导致 glsl 错误:lvalue in assignment too complex
for(int i = 0; i < 4; i++)
{
if(Lgt.lights[i].position.w == 0.0)
{
LightDir[i] = normalize(vec3(Lgt.lights[i].position));
ViewDir[i] = normalize(cameraWorldPosition - worldPosition);
}
else
{
LightDir[i] = normalize(vec3(Lgt.lights[i].position) - worldPosition);
ViewDir[i] = normalize(cameraWorldPosition - worldPosition);
}
}
但是在另一个着色器程序中,一段相同的代码可以正常工作。当代码不包含 if 语句时,例如
for(int i = 0; i < 4; i++)
{
LightDir[i] = normalize(vec3(Lgt.lights[i].position) - worldPosition);
ViewDir[i] = normalize(cameraWorldPosition - worldPosition);
}
一切都很好,但是当我使用乘法时:
for(int i = 0; i < 4; i++)
{
LightDir[i] = LocalMat * normalize(vec3(Lgt.lights[i].position) - worldPosition);
ViewDir[i] = LocalMat * normalize(cameraWorldPosition - worldPosition);
}
我再次收到该错误。谁能告诉发生了什么?