diff --git a/src/consts.cu b/src/consts.cu index 2252c36..72733f6 100644 --- a/src/consts.cu +++ b/src/consts.cu @@ -49,6 +49,6 @@ void copyConstantsToDevice() { // ----------------------- TransferFunction ----------------------- __device__ float d_opacityK; -__device__ float d_sigmoidOne; -__device__ float d_sigmoidTwo; +__device__ float d_sigmoidShift; +__device__ float d_sigmoidExp; __device__ int d_tfComboSelected; diff --git a/src/consts.h b/src/consts.h index 0811c7f..239d58e 100644 --- a/src/consts.h +++ b/src/consts.h @@ -65,8 +65,8 @@ struct ColorStop { // factor for the opacity function extern __device__ float d_opacityK; // sigmoid function variables -extern __device__ float d_sigmoidOne; -extern __device__ float d_sigmoidTwo; +extern __device__ float d_sigmoidShift; +extern __device__ float d_sigmoidExp; // combo box index extern __device__ int d_tfComboSelected; diff --git a/src/gui/input/Widget.cpp b/src/gui/input/Widget.cpp index 92001ef..b6ba24c 100644 --- a/src/gui/input/Widget.cpp +++ b/src/gui/input/Widget.cpp @@ -27,8 +27,8 @@ Widget::Widget(GLFWwindow* window) { this->renderOnce = false; this->opacityK = 0; - this->sigmoidOne = 0.5f; - this->sigmoidTwo = -250.0f; + this->sigmoidShift = 0.5f; + this->sigmoidExp = -250.0f; this->tfComboSelected = 0; }; @@ -50,8 +50,8 @@ void Widget::tick(double fps) { ImGui::Begin("Transfer Function Controls"); ImGui::DragInt("k (log [1e-10, 1])", &this->opacityK, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp); - ImGui::DragFloat("sigmoidOne", &this->sigmoidOne, 0.01f, 0.0f, 1.0f, "%.2f"); - ImGui::InputFloat("sigmoidTwo", &this->sigmoidTwo, 10.0f, 100.0f, "%.0f"); + ImGui::DragFloat("sigmoidShift", &this->sigmoidShift, 0.01f, 0.0f, 1.0f, "%.2f"); + ImGui::InputFloat("sigmoidExp", &this->sigmoidExp, 10.0f, 100.0f, "%.0f"); // 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 @@ -115,8 +115,8 @@ void Widget::copyToDevice() { this->opacityKReal = std::pow(10.0f, (-10 + 0.1 * this->opacityK)); cudaMemcpyToSymbol(&d_opacityK, &this->opacityKReal, sizeof(float)); - cudaMemcpyToSymbol(&d_sigmoidOne, &this->sigmoidOne, sizeof(float)); - cudaMemcpyToSymbol(&d_sigmoidTwo, &this->sigmoidTwo, sizeof(float)); + cudaMemcpyToSymbol(&d_sigmoidShift, &this->sigmoidShift, sizeof(float)); + cudaMemcpyToSymbol(&d_sigmoidExp, &this->sigmoidExp, sizeof(float)); cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(float)); } diff --git a/src/gui/input/Widget.h b/src/gui/input/Widget.h index 15370c7..52727b3 100644 --- a/src/gui/input/Widget.h +++ b/src/gui/input/Widget.h @@ -21,8 +21,8 @@ public: int tfComboSelected; int opacityK; float opacityKReal; - float sigmoidOne; - float sigmoidTwo; + float sigmoidShift; + float sigmoidExp; ImGuiIO io; diff --git a/src/illumination/transferFunction.cu b/src/illumination/transferFunction.cu index 57525af..6930284 100644 --- a/src/illumination/transferFunction.cu +++ b/src/illumination/transferFunction.cu @@ -7,12 +7,12 @@ __device__ float opacityFromGradient(const Vec3 &grad) { float gradMag = grad.length(); - float alpha = 1.0f - expf(-d_opacityK * gradMag); // TODO: This parameter probably has the wrong scale + float alpha = 1.0f - expf(-1 * gradMag); // TODO: This parameter probably has the wrong scale return alpha; } __device__ float opacitySigmoid(float val) { - return 1.0f / (1.0f + expf(d_sigmoidTwo * (val - d_sigmoidOne))); + return 1.0f / (1.0f + expf(d_sigmoidExp * (val - d_sigmoidShift))); } __device__ Color3 colorMap(float normalizedValues, const ColorStop stops[], int N) { diff --git a/src/linalg/mat.cu b/src/linalg/mat.cu index 745ddfb..788867d 100644 --- a/src/linalg/mat.cu +++ b/src/linalg/mat.cu @@ -62,6 +62,7 @@ __device__ Vec3 computeGradient(float* volumeData, const int volW, const int vol float hy = DLON; // y => width => lon float hz = DLEV; // z => depth => alt + // Default float dfdx = (sampleVolumeTrilinear(volumeData, volW, volH, volD, fx + hx, fy, fz) - sampleVolumeTrilinear(volumeData, volW, volH, volD, fx - hx, fy, fz)) / (2.0f * hx); @@ -71,6 +72,14 @@ __device__ Vec3 computeGradient(float* volumeData, const int volW, const int vol float dfdz = (sampleVolumeTrilinear(volumeData, volW, volH, volD, fx, fy, fz + hz) - sampleVolumeTrilinear(volumeData, volW, volH, volD, fx, fy, fz - hz)) / (2.0f * hz); + // // DEBUG (TODO: Delete) - Back to nearest + // float dfdx = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx + 1), (int)roundf(fy), (int)roundf(fz)) - + // sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx - 1), (int)roundf(fy), (int)roundf(fz))) / (2.0f * hx); + // float dfdy = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy + 1), (int)roundf(fz)) - + // sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy - 1), (int)roundf(fz))) / (2.0f * hy); + // float dfdz = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy), (int)roundf(fz + 1)) - + // sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy), (int)roundf(fz - 1))) / (2.0f * hz); + return Vec3::init(dfdx, dfdy, dfdz); };