public override bool Equals(object other) { var otherShader = (Shader)other; var emissive = (EmissiveColor == otherShader.EmissiveColor); var spec = false; var mr = false; if (PbrSpecularGlossiness != null && otherShader.PbrSpecularGlossiness != null) { spec = PbrSpecularGlossiness.Equals(otherShader.PbrSpecularGlossiness); } else if (PbrSpecularGlossiness == null && otherShader.PbrSpecularGlossiness == null) { spec = true; } if (PbrMetallicRoughness != null && otherShader.PbrMetallicRoughness != null) { mr = PbrMetallicRoughness.Equals(otherShader.PbrMetallicRoughness); } else if (PbrMetallicRoughness == null && otherShader.PbrMetallicRoughness == null) { mr = true; } if (spec && emissive && mr) { return(true); } return(false); }
public void ShaderEqualsTest() { var sg = new PbrSpecularGlossiness(); sg.DiffuseColor = "fdfd"; var shaderWithSpecularGlossiness = new Shader(); shaderWithSpecularGlossiness.PbrSpecularGlossiness = sg; shaderWithSpecularGlossiness.EmissiveColor = "#bb3333"; var otherShader = new Shader(); otherShader.EmissiveColor = "#bb3333"; otherShader.PbrSpecularGlossiness = sg; var res = shaderWithSpecularGlossiness.Equals(otherShader); Assert.IsTrue(res); }