Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
孙万捷 authored and 孙万捷 committed Aug 1, 2016
1 parent 8a25f9d commit fd20e37
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gui/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions gui/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Canvas : public QGLWidget
{
this->exposure = exposure;
UpdateCamera();
ReStartRender();
}

// clip plane
Expand Down
32 changes: 32 additions & 0 deletions gui/transferfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
2 changes: 2 additions & 0 deletions gui/transferfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class TransferFunction : public QObject
{
Q_OBJECT
public:
TransferFunction() {}
explicit TransferFunction(vtkSmartPointer<vtkPiecewiseFunction> otf, vtkSmartPointer<vtkColorTransferFunction> ctf, QObject *parent = 0);
~TransferFunction();

cudaTextureObject_t GetCompositeTFTextureObject() {return compositeTex;}
float GetMaxOpacityValue() {return maxOpacity;}
void SaveCurrentTFConfiguration();
void LoadExistingTFConfiguration();
void SetTFConfiguration(uint32_t n, float* index, float* rgb, float* alpha);

signals:
void Changed();
Expand Down
2 changes: 1 addition & 1 deletion pathtracer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit fd20e37

Please sign in to comment.