Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue in webglColormapGenertor file #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/color/webglColormapGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,31 @@ vec4 ' + colormapName + '(float n) {\
vec3 y0 = vec3('+outMinR+', '+outMinG+', '+outMinB+') / 255.0; // min output val\
vec3 y1 = vec3('+outMaxR+', '+outMaxG+', '+outMaxB+') / 255.0; // max output val'

} else {

fn += '\
fn += '\
if ((n >= ' + inMin + ') && (n < ' + inMax + ')) { // input value min and max\
x = vec2('+inMin+', '+inMax+'); // input value min and max in vec2\
y0 = vec3('+outMinR+', '+outMinG+', '+outMinB+') / 255.0; // min output val\
y1 = vec3('+outMaxR+', '+outMaxG+', '+outMaxB+') / 255.0; // max output val'
}';

}
});
}

y1 = vec3('+outMaxR+', '+outMaxG+', '+outMaxB+') / 255.0; // max output val\
} else if(n >= ' + inMax + ') {\
x = vec2(' + inMax + ', ' +inMax+ ');\
y0 = vec3('+outMinR+', '+outMinG+', '+outMinB+') / 255.0;\
y1 = vec3('+outMaxR+', '+outMaxG+', '+outMaxB+') / 255.0;\
}'
// in the original, we used if/else so we do only one range comparison,
// but it's harder to concisely write, so here we're just doing a repeated if statement.

// provide outputs; this is always the same for all colormaps\
fn += 'vec4(\
(n - x[0]) / (x[1] - x[0]) * (y1[0] - y0[0]) + y0[0],\
(n - x[0]) / (x[1] - x[0]) * (y1[1] - y0[1]) + y0[1],\
(n - x[0]) / (x[1] - x[0]) * (y1[2] - y0[2]) + y0[2],\
1.0);\
}'

return fn;
(n - x[0]) / (x[1] - x[0]) * (y1[0] - y0[0]) + y0[0],\
(n - x[0]) / (x[1] - x[0]) * (y1[1] - y0[1]) + y0[1],\
(n - x[0]) / (x[1] - x[0]) * (y1[2] - y0[2]) + y0[2],\
1.0);\
)'
'}'

return fn;
}
});
}
}