From fd20e37cca99f626a7713a09926a25130daa4316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E4=B8=87=E6=8D=B7?= Date: Mon, 1 Aug 2016 08:31:04 +0800 Subject: [PATCH] fixed --- gui/canvas.cpp | 4 ++-- gui/canvas.h | 1 + gui/transferfunction.cpp | 32 ++++++++++++++++++++++++++++++++ gui/transferfunction.h | 2 ++ pathtracer.cu | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/gui/canvas.cpp b/gui/canvas.cpp index d7704cd..761dc8d 100644 --- a/gui/canvas.cpp +++ b/gui/canvas.cpp @@ -69,7 +69,7 @@ void Canvas::paintGL() if(renderMode == RENDER_MODE_RAYCASTING) { - glEnable(GL_BLEND); + /*glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); @@ -84,7 +84,7 @@ void Canvas::paintGL() glColor4f(0.9490f, 0.9647f, 0.9803f, 1.f); glVertex2f(1.f, -1.f); - glEnd(); + glEnd();*/ render_raycasting(img, deviceVolume, transferFunction, camera, volumeReader.GetElementBoundingSphereRadius()); } diff --git a/gui/canvas.h b/gui/canvas.h index 76ff693..9826458 100644 --- a/gui/canvas.h +++ b/gui/canvas.h @@ -142,6 +142,7 @@ class Canvas : public QGLWidget { this->exposure = exposure; UpdateCamera(); + ReStartRender(); } // clip plane diff --git a/gui/transferfunction.cpp b/gui/transferfunction.cpp index 276a8af..a98dbca 100644 --- a/gui/transferfunction.cpp +++ b/gui/transferfunction.cpp @@ -176,3 +176,35 @@ void TransferFunction::onColorTFChanged() //signal changed Changed(); } + +void TransferFunction::SetTFConfiguration(uint32_t n, float *index, float *rgb, float *alpha) +{ + opacityTF->RemoveAllPoints(); + colorTF->RemoveAllPoints(); + + for(auto i = 0; i < n; ++i) + { + opacityTF->AddPoint(index[i], alpha[i]); + colorTF->AddRGBPoint(index[i], rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]); + } + + if(compositeTex) + { + checkCudaErrors(cudaDestroyTextureObject(compositeTex)); + compositeTex = 0; + } + + opacityTF->GetTable(0.0, 1.0, TABLE_SIZE, opacityTable); + colorTF->GetTable(0.0, 1.0, TABLE_SIZE, colorTable); + size_t j = 0, k = 0; + for(size_t i = 0; i < TABLE_SIZE; ++i) + { + compositeTable[j++] = colorTable[k++]; + compositeTable[j++] = colorTable[k++]; + compositeTable[j++] = colorTable[k++]; + compositeTable[j++] = opacityTable[i]; + } + + checkCudaErrors(cudaMemcpyToArray(array, 0, 0, compositeTable, sizeof(float) * TABLE_SIZE * 4, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaCreateTextureObject(&compositeTex, &resourceDesc, &texDesc, NULL)); +} diff --git a/gui/transferfunction.h b/gui/transferfunction.h index adb7033..023d775 100644 --- a/gui/transferfunction.h +++ b/gui/transferfunction.h @@ -31,6 +31,7 @@ class TransferFunction : public QObject { Q_OBJECT public: + TransferFunction() {} explicit TransferFunction(vtkSmartPointer otf, vtkSmartPointer ctf, QObject *parent = 0); ~TransferFunction(); @@ -38,6 +39,7 @@ class TransferFunction : public QObject float GetMaxOpacityValue() {return maxOpacity;} void SaveCurrentTFConfiguration(); void LoadExistingTFConfiguration(); + void SetTFConfiguration(uint32_t n, float* index, float* rgb, float* alpha); signals: void Changed(); diff --git a/pathtracer.cu b/pathtracer.cu index 8931008..8a645a5 100644 --- a/pathtracer.cu +++ b/pathtracer.cu @@ -168,7 +168,7 @@ __inline__ __device__ glm::vec3 sample_bsdf(const VolumeSample& vs, glm::vec3* w return glm::vec3(0.f); } -__inline__ __device__ glm::vec3 estimate_direct_light(const VolumeSample vs, curandState& rng, ShadingType st) +__inline__ __device__ glm::vec3 estimate_direct_light(const VolumeSample& vs, curandState& rng, ShadingType st) { glm::vec3 Li = glm::vec3(0.f);