mirror of
https://github.com/MartinOpat/cuda-based-raytrace.git
synced 2025-06-07 02:13:10 +02:00
added levoy transfer function
This commit is contained in:
1 parent
bae68db6b8
commit
9f7700ae80
6 files changed
+66
-39
No files matched your search
@@ -92,7 +92,6 @@ void Window::free(float* data) {
|
||||
|
||||
|
||||
void Window::tick() {
|
||||
std::cout << "tick tick\n";
|
||||
// manually track time diff
|
||||
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||
float diff = (float) std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_frame).count();
|
||||
@@ -101,12 +100,10 @@ void Window::tick() {
|
||||
// input
|
||||
this->widget->tick(1000.0/diff);
|
||||
|
||||
std::cout << "setting tick render\n";
|
||||
// tick render
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
std::cout << "blabla\n";
|
||||
if (!this->widget->paused) this->quad->render();
|
||||
this->shader->use();
|
||||
glBindVertexArray(this->quad->VAO);
|
||||
@@ -114,14 +111,11 @@ void Window::tick() {
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6); // draw current frame to texture
|
||||
|
||||
// render ImGui context
|
||||
std::cout << "rendering\n";
|
||||
this->widget->render();
|
||||
std::cout << "done rendering\n";
|
||||
|
||||
// check for events
|
||||
glfwSwapBuffers(this->window);
|
||||
glfwPollEvents();
|
||||
std::cout << "done tick tick\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,12 @@ Widget::Widget(GLFWwindow* window) {
|
||||
this->sigmoidExp = -250.0f;
|
||||
this->alphaAcumLimit = 0.4f;
|
||||
this->tfComboSelected = 2;
|
||||
this->tfComboSelectedColor = 0;
|
||||
this->opacityConst = 100;
|
||||
this->showSilhouettes = false;
|
||||
this->silhouettesThreshold = 0.02f;
|
||||
this->levoyFocus = 0.5;
|
||||
this->levoyWidth = 1;
|
||||
};
|
||||
|
||||
// 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.
|
||||
@@ -73,13 +76,18 @@ void Widget::tick(double fps) {
|
||||
ImGui::InputFloat("Sig. sxp", &this->sigmoidExp, 10.0f, 100.0f, "%.0f");
|
||||
ImGui::DragFloat("Alpha accum. limit", &this->alphaAcumLimit, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::DragInt("Opacity const. (log [1e-5, 1])", &this->opacityConst, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::DragFloat("Levoy Width", &this->levoyWidth, 0.01f, 0.0f, 100.0f, "%.2f");
|
||||
// ImGui::DragFloat("Levoy Focus", &this->levoyFocus, 0.01f, 250.0f, 350.0f, "%.2f");
|
||||
ImGui::DragFloat("Levoy Focus", &this->levoyFocus, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
|
||||
// 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
|
||||
// whatever value is selected here is available on the gpu as d_tfComboSelected.
|
||||
const char* items[] = {"Opacity - gradient", "Opacity - sigmoid", "Opacity - constant", "..."};
|
||||
const char* items[] = {"Opacity - gradient", "Opacity - sigmoid", "Opacity - constant", "Opacity - levoy"};
|
||||
if (ImGui::BeginCombo("Transfer function", items[this->tfComboSelected])) {
|
||||
// std::cout << "hello???\n";
|
||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
|
||||
// std::cout << "letsssssa a asdfa???\n";
|
||||
const bool is_selected = (this->tfComboSelected == n);
|
||||
if (ImGui::Selectable(items[n], is_selected))
|
||||
this->tfComboSelected = n;
|
||||
@@ -171,11 +179,14 @@ void Widget::copyToDevice() {
|
||||
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(int));
|
||||
cudaMemcpyToSymbol(&d_showSilhouettes, &this->showSilhouettes, sizeof(bool));
|
||||
cudaMemcpyToSymbol(&d_silhouettesThreshold, &this->silhouettesThreshold, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_levoyFocus, &this->levoyFocus, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_levoyWidth, &this->levoyWidth, sizeof(float));
|
||||
|
||||
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() {
|
||||
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
float opacityConstReal;
|
||||
bool showSilhouettes;
|
||||
float silhouettesThreshold;
|
||||
float levoyFocus;
|
||||
float levoyWidth;
|
||||
|
||||
ImGuiIO io;
|
||||
|
||||
|
||||