Does GLM have an equivalent to the Hadamard/Schur product

Viewed 115

I am using the glm library and I was curious if glm already has the schur/hadamard product implemented. I have found the compMul call, but it doesn't seem to be the call I want. I know that writing this myself is trivial, but I'd like to avoid duplication if possible. Thanks.

1 Answers

GLM already supports Hadamard/Schur product through * operator. It is known as component-wise multiplication. For instance:

glm::vec3 color1(1.0f, 0.2f, 0.4f);
glm::vec3 color2(0.9f, 1.0f, 0.1f);
glm::vec3 blended_color = color1 * color2; // = (0.9f, 0.2f, 0.04f);
Related