Added silhoutte gui control

This commit is contained in:
Martin Opat 2025-01-15 20:31:40 +01:00
parent b4c7d3a7a5
commit d5df4ea188
5 changed files with 15 additions and 1 deletions

View File

@ -55,6 +55,8 @@ __device__ float d_alphaAcumLimit;
__device__ int d_tfComboSelected;
__device__ int d_tfComboSelectedColor;
__device__ float d_opacityConst;
__device__ bool d_showSilhouettes;
__device__ float d_silhouettesThreshold;
// ----------------------- Raycasting -----------------------
__device__ int d_samplesPerPixel;

View File

@ -73,6 +73,9 @@ extern __device__ int d_tfComboSelectedColor;
extern __device__ float d_opacityConst;
// samples per pixel
extern __device__ int d_samplesPerPixel;
// Silhouettes
extern __device__ bool d_showSilhouettes;
extern __device__ float d_silhouettesThreshold;
const int lenStopsPythonLike = 5;
const int lenStopsGrayscale = 2;

View File

@ -33,6 +33,8 @@ Widget::Widget(GLFWwindow* window) {
this->alphaAcumLimit = 0.4f;
this->tfComboSelected = 0;
this->opacityConst = 100;
this->showSilhouettes = true;
this->silhouettesThreshold = 0.02f;
};
// 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.
@ -85,6 +87,9 @@ void Widget::tick(double fps) {
}
ImGui::EndCombo();
}
if (ImGui::Button(this->showSilhouettes ? "Hide Silhouettes" : "Show Silhouettes")) this->showSilhouettes = !this->showSilhouettes;
ImGui::DragFloat("Silhouettes threshold", &this->silhouettesThreshold, 0.001f, 0.0f, 0.5f, "%.3f");
ImGui::End();
ImGui::Begin("Light Controls");
@ -138,6 +143,8 @@ void Widget::copyToDevice() {
cudaMemcpyToSymbol(&d_sigmoidExp, &this->sigmoidExp, sizeof(float));
cudaMemcpyToSymbol(&d_alphaAcumLimit, &this->alphaAcumLimit, sizeof(float));
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(int));
cudaMemcpyToSymbol(&d_showSilhouettes, &this->showSilhouettes, sizeof(bool));
cudaMemcpyToSymbol(&d_silhouettesThreshold, &this->silhouettesThreshold, sizeof(float));
this->opacityConstReal = std::pow(10.0f, (-5 + 0.05 * this->opacityConst));
cudaMemcpyToSymbol(&d_opacityConst, &this->opacityConstReal, sizeof(float));

View File

@ -28,6 +28,8 @@ public:
float alphaAcumLimit;
int opacityConst;
float opacityConstReal;
bool showSilhouettes;
float silhouettesThreshold;
ImGuiIO io;

View File

@ -106,7 +106,7 @@ __device__ float4 transferFunction(float density, const Vec3& grad, const Point3
// --------------------------- Silhouettes ---------------------------
Vec3 N = grad.normalize();
if (grad.length() > 0.2f && fabs(N.dot(viewDir)) < 0.02f) {
if (d_showSilhouettes && grad.length() > 0.2f && fabs(N.dot(viewDir)) < d_silhouettesThreshold) {
result.x = 0.0f;
result.y = 0.0f;
result.z = 0.0f;