Implemented picker for color map
This commit is contained in:
parent
33365a26a7
commit
4b95bb728d
|
|
@ -52,4 +52,5 @@ __device__ float d_opacityK;
|
|||
__device__ float d_sigmoidShift;
|
||||
__device__ float d_sigmoidExp;
|
||||
__device__ int d_tfComboSelected;
|
||||
__device__ int d_tfComboSelectedColor;
|
||||
__device__ float d_opacityConst;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ extern __device__ float d_sigmoidShift;
|
|||
extern __device__ float d_sigmoidExp;
|
||||
// combo box index
|
||||
extern __device__ int d_tfComboSelected;
|
||||
extern __device__ int d_tfComboSelectedColor;
|
||||
// constant opacity option
|
||||
extern __device__ float d_opacityConst;
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,21 @@ void Widget::tick(double fps) {
|
|||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
// Same comments as above apply
|
||||
const char* items2[] = {"Python-like", "BPR", "Greyscale", "..."};
|
||||
if (ImGui::BeginCombo("ComboBox for color map", items2[this->tfComboSelectedColor]))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(items2); n++)
|
||||
{
|
||||
const bool is_selected = (this->tfComboSelectedColor == n);
|
||||
if (ImGui::Selectable(items2[n], is_selected))
|
||||
this->tfComboSelectedColor = n;
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Begin("Light Controls");
|
||||
|
|
@ -119,10 +134,12 @@ void Widget::copyToDevice() {
|
|||
|
||||
cudaMemcpyToSymbol(&d_sigmoidShift, &this->sigmoidShift, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_sigmoidExp, &this->sigmoidExp, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(int));
|
||||
|
||||
this->opacityConstReal = std::pow(10.0f, (-5 + 0.05 * this->opacityConst));
|
||||
cudaMemcpyToSymbol(&d_opacityConst, &this->opacityConstReal, sizeof(float));
|
||||
|
||||
cudaMemcpyToSymbol(&d_tfComboSelectedColor, &this->tfComboSelectedColor, sizeof(int));
|
||||
}
|
||||
|
||||
Widget::~Widget() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public:
|
|||
char* fps;
|
||||
|
||||
int tfComboSelected;
|
||||
int tfComboSelectedColor;
|
||||
int opacityK;
|
||||
float opacityKReal;
|
||||
float sigmoidShift;
|
||||
|
|
|
|||
|
|
@ -40,17 +40,35 @@ __device__ float4 transferFunction(float density, const Vec3& grad, const Point3
|
|||
|
||||
// --------------------------- Sample the volume ---------------------------
|
||||
// TODO: Somehow pick if to use temp of speed normalization ... or pass extremas as params.
|
||||
float normDensity = (density - MIN_TEMP) / (MAX_TEMP - MIN_TEMP);
|
||||
// float normDensity = (density - MIN_TEMP) / (MAX_TEMP - MIN_TEMP);
|
||||
float normDensity = (density - 273) / (MAX_TEMP - MIN_TEMP)+16.f/21.f; // Make zero match Celsius zero
|
||||
|
||||
// float normDensity = (density - MIN_SPEED) / (MAX_SPEED - MIN_SPEED);
|
||||
|
||||
normDensity = clamp(normDensity, 0.0f, 1.0f);
|
||||
|
||||
// --------------------------- Map density to color ---------------------------
|
||||
// TODO: Add a way to pick stops here
|
||||
Color3 baseColor = colorMap(normDensity, d_stopsPythonLike, lenStopsPythonLike);
|
||||
// Pick color map
|
||||
Color3 baseColor;
|
||||
switch (d_tfComboSelectedColor) {
|
||||
case 0:
|
||||
baseColor = colorMap(normDensity, d_stopsPythonLike, lenStopsPythonLike);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
baseColor = colorMap(normDensity, d_stopsBluePurleRed, lenStopsBluePurpleRed);
|
||||
break;
|
||||
|
||||
// TODO: This is a Gui select element
|
||||
// TODO: Add a way to pick different function for alpha
|
||||
case 2:
|
||||
baseColor = colorMap(normDensity, d_stopsGrayscale, lenStopsGrayscale);
|
||||
break;
|
||||
|
||||
default:
|
||||
baseColor = colorMap(normDensity, d_stopsPythonLike, lenStopsPythonLike);
|
||||
break;
|
||||
}
|
||||
|
||||
// Pick opacity function
|
||||
float alpha;
|
||||
switch (d_tfComboSelected) {
|
||||
case 0:
|
||||
|
|
|
|||
Loading…
Reference in New Issue