levoy transfer function
This commit is contained in:
parent
9f7700ae80
commit
5a629815e7
|
|
@ -48,6 +48,8 @@ __device__ Vec3 d_cameraDir;
|
|||
__device__ Point3 d_lightPos;
|
||||
__device__ Color3 d_backgroundColor;
|
||||
__device__ Vec3 d_cameraUp;
|
||||
__device__ double d_specularStrength;
|
||||
__device__ int d_shininess;
|
||||
|
||||
Vec3 h_cameraUp = Vec3::init(0.0, 1.0, 0.0).normalize();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ const float stepSize = 0.02f;
|
|||
// Shading consts
|
||||
const double ambientStrength = 0.3;
|
||||
const double diffuseStrength = 0.8;
|
||||
const double specularStrength = 0.5;
|
||||
const int shininess = 32;
|
||||
extern __device__ double d_specularStrength; // = 0.5;
|
||||
extern __device__ int d_shininess; // = 32;
|
||||
const float fov = 60.0f * (M_PI / 180.0f);
|
||||
|
||||
// Camera and Light
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ Widget::Widget(GLFWwindow* window) {
|
|||
this->silhouettesThreshold = 0.02f;
|
||||
this->levoyFocus = 0.5;
|
||||
this->levoyWidth = 1;
|
||||
this->specularStrength = 0.5;
|
||||
this->shininess = 32;
|
||||
};
|
||||
|
||||
// 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.
|
||||
|
|
@ -71,6 +73,8 @@ void Widget::tick(double fps) {
|
|||
float min = -1, max = 1;
|
||||
|
||||
ImGui::Begin("Transfer Function Controls");
|
||||
ImGui::DragFloat("Specular Strength", &this->specularStrength, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::DragInt("Shininess", &this->shininess, 1, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::DragInt("Grad. exp. (log [1e-10, 1])", &this->opacityK, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::DragFloat("Sig. shift", &this->sigmoidShift, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::InputFloat("Sig. sxp", &this->sigmoidExp, 10.0f, 100.0f, "%.0f");
|
||||
|
|
@ -181,6 +185,9 @@ void Widget::copyToDevice() {
|
|||
cudaMemcpyToSymbol(&d_silhouettesThreshold, &this->silhouettesThreshold, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_levoyFocus, &this->levoyFocus, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_levoyWidth, &this->levoyWidth, sizeof(float));
|
||||
double specularStrengthDouble = this->specularStrength;
|
||||
cudaMemcpyToSymbol(&d_specularStrength, &specularStrengthDouble, sizeof(double));
|
||||
cudaMemcpyToSymbol(&d_shininess, &this->shininess, sizeof(int));
|
||||
|
||||
this->opacityConstReal = std::pow(10.0f, (-5 + 0.05 * this->opacityConst));
|
||||
cudaMemcpyToSymbol(&d_opacityConst, &this->opacityConstReal, sizeof(float));
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public:
|
|||
float silhouettesThreshold;
|
||||
float levoyFocus;
|
||||
float levoyWidth;
|
||||
float specularStrength;
|
||||
int shininess;
|
||||
|
||||
ImGuiIO io;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ __device__ Vec3 phongShading(const Vec3& normal, const Vec3& lightDir, const Vec
|
|||
Vec3 diffuse = baseColor * (diffuseStrength * diff);
|
||||
|
||||
Vec3 reflectDir = (normal * (2.0 * normal.dot(lightDir)) - lightDir).normalize();
|
||||
double spec = pow(fmax(viewDir.dot(reflectDir), 0.0), shininess);
|
||||
Vec3 specular = Vec3::init(1.0, 1.0, 1.0) * (specularStrength * spec);
|
||||
double spec = pow(fmax(viewDir.dot(reflectDir), 0.0), d_shininess);
|
||||
Vec3 specular = Vec3::init(1.0, 1.0, 1.0) * (d_specularStrength * spec);
|
||||
|
||||
return ambient + diffuse + specular;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ __device__ float4 transferFunction(float density, const Vec3& grad, const Point3
|
|||
result.x = 0.0f;
|
||||
result.y = 0.0f;
|
||||
result.z = 0.0f;
|
||||
// result.w = alpha;
|
||||
result.w = d_opacityConst;
|
||||
result.w = alpha;
|
||||
// result.w = d_opacityConst;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue