unsuccessul so far to refactor glsl for macOS.

This commit is contained in:
Michael James 2018-03-20 19:28:45 -06:00
parent ecba2d3094
commit 02750d5a25

View file

@ -29,7 +29,7 @@ int toBitMask(float alpha) {
} }
float fromBitMask(int bitMask) { float fromBitMask(int bitMask) {
return bitMask / maskMultiplier; return float(bitMask) / maskMultiplier;
} }
vec4 getFinalColor() { vec4 getFinalColor() {
@ -68,8 +68,6 @@ vec4 applyColorBand(int colorband) {
float cmapValue = dataToColorMapValue(dataValue, dataMappingDataValues, dataMappingColorValues, dataMappingValues); float cmapValue = dataToColorMapValue(dataValue, dataMappingDataValues, dataMappingColorValues, dataMappingValues);
float index = pow(getColorMappingIndex(cmapValue, colorMapping), gamma); float index = pow(getColorMappingIndex(cmapValue, colorMapping), gamma);
int currentMask = toBitMask(a);
int bitValue = (1 << band);
if (colorband == RED_BAND && index > r) { if (colorband == RED_BAND && index > r) {
r = index; r = index;
} else if (colorband == GREEN_BAND && index > g) { } else if (colorband == GREEN_BAND && index > g) {
@ -77,11 +75,13 @@ vec4 applyColorBand(int colorband) {
} else if (colorband == BLUE_BAND && index > b) { } else if (colorband == BLUE_BAND && index > b) {
b = index; b = index;
} }
int bitValue = int(pow(2.0,float(band)));
if ((currentMask & bitValue) == 0) { int currentMask = toBitMask(a);
// alpha does not contain this bit yet! if ((currentMask - (bitValue * int(floor(float(currentMask/bitValue))))) == 0) {
a = fromBitMask(currentMask | bitValue); a = fromBitMask(bitValue);
} }
// a mod n = a - (n * Fix(a/n))
// currentMask & bitValue = currentMask - (bitValue * (currentMask/bitValue))
} }
return vec4(r, g, b, a); return vec4(r, g, b, a);