adding the ability to turn off background compositing for volume renderer

This commit is contained in:
Matt Larsen 2017-02-09 16:26:23 -08:00
parent 3fe918ce4d
commit 1f6ef23b98
3 changed files with 22 additions and 5 deletions

@ -40,6 +40,7 @@ struct MapperVolume::InternalsType
{
vtkm::rendering::CanvasRayTracer *Canvas;
vtkm::Float32 SampleDistance;
bool CompositeBackground;
vtkm::cont::internal::RuntimeDeviceTracker DeviceTracker;
std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>
RayTracerContainer;
@ -47,7 +48,8 @@ struct MapperVolume::InternalsType
VTKM_CONT
InternalsType()
: Canvas(nullptr),
SampleDistance(-1.f)
SampleDistance(-1.f),
CompositeBackground(true)
{ }
template<typename Device>
@ -149,6 +151,7 @@ struct MapperVolume::RenderFunctor
tracer->GetCamera().SetParameters(this->Camera,
*this->Self->Internals->Canvas);
tracer->SetSampleDistance(this->Self->Internals->SampleDistance);
tracer->SetCompositeBackground(this->Self->Internals->CompositeBackground);
vtkm::Bounds dataBounds = this->Coordinates.GetBounds(Device());
tracer->SetData(this->Coordinates,
@ -213,5 +216,10 @@ void MapperVolume::SetSampleDistance(const vtkm::Float32 sampleDistance)
this->Internals->SampleDistance = sampleDistance;
}
void MapperVolume::SetCompositeBackground(const bool compositeBackground)
{
this->Internals->CompositeBackground = compositeBackground;
}
}
} // namespace vtkm::rendering

@ -49,6 +49,7 @@ public:
vtkm::rendering::Mapper *NewCopy() const VTKM_OVERRIDE;
void SetSampleDistance(const vtkm::Float32 distance);
void SetCompositeBackground(const bool compositeBackground);
private:
struct InternalsType;
std::shared_ptr<InternalsType> Internals;

@ -943,6 +943,7 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
IsSceneDirty = false;
IsUniformDataSet = true;
SampleDistance = -1.f;
DoCompositeBackground = false;
}
VTKM_CONT
@ -1078,10 +1079,11 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
}
}
vtkm::worklet::DispatcherMapField< CompositeBackground >( CompositeBackground( BackgroundColor ) )
.Invoke( camera.FrameBuffer );
if(DoCompositeBackground)
{
vtkm::worklet::DispatcherMapField< CompositeBackground >( CompositeBackground( BackgroundColor ) )
.Invoke( camera.FrameBuffer );
}
camera.WriteToSurface(canvas, Rays.MinDistance);
} //Render
@ -1099,9 +1101,15 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
BackgroundColor = backgroundColor;
}
void SetCompositeBackground(bool compositeBackground)
{
DoCompositeBackground = compositeBackground;
}
protected:
bool IsSceneDirty;
bool IsUniformDataSet;
bool DoCompositeBackground;
VolumeRay<DeviceAdapter> Rays;
Camera<DeviceAdapter> camera;
vtkm::cont::DynamicArrayHandleCoordinateSystem Coordinates;