diff --git a/src/consts.cu b/src/consts.cu index fc9d1b9..ed48441 100644 --- a/src/consts.cu +++ b/src/consts.cu @@ -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; diff --git a/src/consts.h b/src/consts.h index dcfa599..7d739a3 100644 --- a/src/consts.h +++ b/src/consts.h @@ -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; diff --git a/src/gui/input/Widget.cpp b/src/gui/input/Widget.cpp index 03f3a04..1dfd3ef 100644 --- a/src/gui/input/Widget.cpp +++ b/src/gui/input/Widget.cpp @@ -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() { diff --git a/src/gui/input/Widget.h b/src/gui/input/Widget.h index c2fe991..ac2cbcd 100644 --- a/src/gui/input/Widget.h +++ b/src/gui/input/Widget.h @@ -19,6 +19,7 @@ public: char* fps; int tfComboSelected; + int tfComboSelectedColor; int opacityK; float opacityKReal; float sigmoidShift; diff --git a/src/illumination/transferFunction.cu b/src/illumination/transferFunction.cu index 0cb3271..060548a 100644 --- a/src/illumination/transferFunction.cu +++ b/src/illumination/transferFunction.cu @@ -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: