Added log slider for opacity const option
This commit is contained in:
parent
edcde639da
commit
30182885f8
|
|
@ -52,3 +52,4 @@ __device__ float d_opacityK;
|
||||||
__device__ float d_sigmoidShift;
|
__device__ float d_sigmoidShift;
|
||||||
__device__ float d_sigmoidExp;
|
__device__ float d_sigmoidExp;
|
||||||
__device__ int d_tfComboSelected;
|
__device__ int d_tfComboSelected;
|
||||||
|
__device__ float d_opacityConst;
|
||||||
|
|
|
||||||
|
|
@ -62,13 +62,15 @@ struct ColorStop {
|
||||||
Color3 color;
|
Color3 color;
|
||||||
};
|
};
|
||||||
|
|
||||||
// factor for the opacity function
|
// factor for the gradient opacity function
|
||||||
extern __device__ float d_opacityK;
|
extern __device__ float d_opacityK;
|
||||||
// sigmoid function variables
|
// sigmoid function variables
|
||||||
extern __device__ float d_sigmoidShift;
|
extern __device__ float d_sigmoidShift;
|
||||||
extern __device__ float d_sigmoidExp;
|
extern __device__ float d_sigmoidExp;
|
||||||
// combo box index
|
// combo box index
|
||||||
extern __device__ int d_tfComboSelected;
|
extern __device__ int d_tfComboSelected;
|
||||||
|
// constant opacity option
|
||||||
|
extern __device__ float d_opacityConst;
|
||||||
|
|
||||||
const int lenStopsPythonLike = 5;
|
const int lenStopsPythonLike = 5;
|
||||||
const int lenStopsGrayscale = 2;
|
const int lenStopsGrayscale = 2;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ Widget::Widget(GLFWwindow* window) {
|
||||||
this->sigmoidShift = 0.5f;
|
this->sigmoidShift = 0.5f;
|
||||||
this->sigmoidExp = -250.0f;
|
this->sigmoidExp = -250.0f;
|
||||||
this->tfComboSelected = 0;
|
this->tfComboSelected = 0;
|
||||||
|
this->opacityConst = 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
// REFACTOR: should probably not have all the logic in one function; something like a list of ImplementedWidgets with each a Render() function (a la interface) would be better.
|
// REFACTOR: should probably not have all the logic in one function; something like a list of ImplementedWidgets with each a Render() function (a la interface) would be better.
|
||||||
|
|
@ -52,6 +53,7 @@ void Widget::tick(double fps) {
|
||||||
ImGui::DragInt("Gradient exp. (log [1e-10, 1])", &this->opacityK, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
ImGui::DragInt("Gradient exp. (log [1e-10, 1])", &this->opacityK, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||||
ImGui::DragFloat("sigmoidShift", &this->sigmoidShift, 0.01f, 0.0f, 1.0f, "%.2f");
|
ImGui::DragFloat("sigmoidShift", &this->sigmoidShift, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||||
ImGui::InputFloat("sigmoidExp", &this->sigmoidExp, 10.0f, 100.0f, "%.0f");
|
ImGui::InputFloat("sigmoidExp", &this->sigmoidExp, 10.0f, 100.0f, "%.0f");
|
||||||
|
ImGui::DragInt("Opacity constant (log [1e-5, 1])", &this->opacityConst, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
|
||||||
// the items[] contains the entries for the combobox. The selected index is stored as an int on this->tfComboSelected
|
// the items[] contains the entries for the combobox. The selected index is stored as an int on this->tfComboSelected
|
||||||
// the default entry is set in the constructor, so if you want that to be a specific entry just change it
|
// the default entry is set in the constructor, so if you want that to be a specific entry just change it
|
||||||
|
|
@ -118,6 +120,9 @@ void Widget::copyToDevice() {
|
||||||
cudaMemcpyToSymbol(&d_sigmoidShift, &this->sigmoidShift, sizeof(float));
|
cudaMemcpyToSymbol(&d_sigmoidShift, &this->sigmoidShift, sizeof(float));
|
||||||
cudaMemcpyToSymbol(&d_sigmoidExp, &this->sigmoidExp, sizeof(float));
|
cudaMemcpyToSymbol(&d_sigmoidExp, &this->sigmoidExp, sizeof(float));
|
||||||
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(float));
|
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(float));
|
||||||
|
|
||||||
|
this->opacityConstReal = std::pow(10.0f, (-5 + 0.05 * this->opacityConst));
|
||||||
|
cudaMemcpyToSymbol(&d_opacityConst, &this->opacityConstReal, sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget::~Widget() {
|
Widget::~Widget() {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ public:
|
||||||
float opacityKReal;
|
float opacityKReal;
|
||||||
float sigmoidShift;
|
float sigmoidShift;
|
||||||
float sigmoidExp;
|
float sigmoidExp;
|
||||||
|
int opacityConst;
|
||||||
|
float opacityConstReal;
|
||||||
|
|
||||||
ImGuiIO io;
|
ImGuiIO io;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ __device__ float4 transferFunction(float density, const Vec3& grad, const Point3
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
alpha = 0.1f;
|
alpha = d_opacityConst;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue