Commit 938c8790 authored by Aashish Chaudhary's avatar Aashish Chaudhary

Fixed issues with interactive volume rendering

parent 3d3f264c
......@@ -74,30 +74,35 @@ int TestGPURayCastAdditive(int argc,
t->Update();
vtkRenderWindow *renWin=vtkRenderWindow::New();
vtkRenderer *ren1=vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderer *ren1 = vtkRenderer::New();
ren1->SetBackground(0.1,0.4,0.2);
renWin->AddRenderer(ren1);
ren1->Delete();
renWin->SetSize(301,300); // intentional odd and NPOT width/height
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
// intentional odd and NPOT width/height
renWin->SetSize(301,300);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renWin->Delete();
renWin->Render(); // make sure we have an OpenGL context.
// make sure we have an OpenGL context.
renWin->Render();
vtkGPUVolumeRayCastMapper *volumeMapper;
vtkVolumeProperty *volumeProperty;
vtkVolume *volume;
volumeMapper=vtkGPUVolumeRayCastMapper::New();
volumeMapper = vtkGPUVolumeRayCastMapper::New();
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetSampleDistance(0.2);
volumeMapper->SetBlendModeToComposite(); // composite first
volumeMapper->SetInputConnection(
t->GetOutputPort());
volumeProperty=vtkVolumeProperty::New();
volumeProperty = vtkVolumeProperty::New();
volumeProperty->ShadeOff();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
......
......@@ -1903,9 +1903,8 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateSamplingDistance(
if (this->Parent->ReductionFactor < 1.0)
{
// 0.5 is done to increase the impact factor
this->ActualSampleDistance /=
static_cast<GLfloat>(this->Parent->ReductionFactor * 0.5);
static_cast<GLfloat>(this->Parent->ReductionFactor);
}
}
}
......@@ -2472,32 +2471,25 @@ void vtkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor(
double fullTime = timeToDraw / this->ReductionFactor;
double newFactor = allocatedTime / fullTime;
if ( oldFactor == 1.0 ||
newFactor / oldFactor > 1.3 ||
newFactor / oldFactor < .95 )
{
this->ReductionFactor = (newFactor+oldFactor)/2.0;
this->ReductionFactor = (newFactor+oldFactor)/2.0;
this->ReductionFactor = (this->ReductionFactor > 5.0) ? (1.00) :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor > 1.0) ? (0.99) :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor < 0.1) ? (0.10) :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor > 1.0) ? 1.0 :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor < 1.0) ? (0.5) :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor < 0.5) ? (0.25) :
(this->ReductionFactor);
this->ReductionFactor = (this->ReductionFactor < 0.25) ? (0.1) :
(this->ReductionFactor);
if ( 1.0/this->ReductionFactor > this->MaximumImageSampleDistance )
{
this->ReductionFactor = 1.0 / this->MaximumImageSampleDistance;
}
if ( 1.0/this->ReductionFactor < this->MinimumImageSampleDistance )
{
this->ReductionFactor = 1.0 / this->MinimumImageSampleDistance;
}
if ( 1.0/this->ReductionFactor > this->MaximumImageSampleDistance )
{
this->ReductionFactor = 1.0 / this->MaximumImageSampleDistance;
}
if ( 1.0/this->ReductionFactor < this->MinimumImageSampleDistance )
{
this->ReductionFactor = 1.0 / this->MinimumImageSampleDistance;
}
}
else
{
this->ReductionFactor = 1.0;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment