比较 GLSL 中的结构

Comparing structs in GLSL

使用经典的相等运算符比较两个相同类型的结构是否安全?我还没有找到关于此的任何信息,并且没有选项可以在 GLSL 中重载此运算符。那么 GLSL 是否默认比较两个结构的组件?

struct sith
{
   int forceLevel;
   vec3 saberColor;
};
...
sith vader = sith(100,vec3(1.0,0.0,0.0));
sith anakin = sith(100,vec3(1.0,0.0,0.0));
...
if (vader == anakin)
   //is the force strong with this one?

When using the equality operators, two structures are equal if and only if all the fields are component-wise equal, and two arrays are equal if and only if all the elements are element-wise equal

- GLSL 1.30 Specification, Page 46, Section 5.7 "Structure and Array Operations"