Texture as data in shader has odd behavior

Dealing with floating points it’s common to have to deal with small precisions errors. Checking for equality with floating points, other than perhaps 0.0, is almost always a mistake. If you are using colors to indicate discrete integer values I suggest you convert them to integers by multiplying and rounding.

int num = int(floor(255.0 * data.r + 0.5));
1 Like