Commit df185a67 authored by Matt Larsen's avatar Matt Larsen
Browse files

removing background colors from tracers. Background color is now the responsiblitiy of the canvas.

parent 28b1e6b1
......@@ -112,8 +112,6 @@ void MapperRayTracer::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
coords.GetData(), indices, scalarField, numberOfTriangles, scalarRange, dataBounds);
this->Internals->Tracer.SetColorMap(this->ColorMap);
this->Internals->Tracer.SetBackgroundColor(
this->Internals->Canvas->GetBackgroundColor().Components);
this->Internals->Tracer.Render(this->Internals->Rays);
timer.Reset();
......
......@@ -128,7 +128,6 @@ void MapperVolume::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
tracer.SetData(
coords, scalarField, cellset.Cast<vtkm::cont::CellSetStructured<3>>(), scalarRange);
tracer.SetColorMap(this->ColorMap);
tracer.SetBackgroundColor(this->Internals->Canvas->GetBackgroundColor().Components);
tracer.Render(rays);
......
......@@ -283,7 +283,6 @@ public:
vtkm::Float32 SpecularExponent;
vtkm::Vec<vtkm::Float32, 3> CameraPosition;
vtkm::Vec<vtkm::Float32, 3> LookAt;
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
public:
VTKM_CONT
......@@ -291,14 +290,12 @@ public:
const vtkm::Int32& colorMapSize,
const vtkm::Vec<vtkm::Float32, 3>& lightPosition,
const vtkm::Vec<vtkm::Float32, 3>& cameraPosition,
const vtkm::Vec<vtkm::Float32, 3>& lookAt,
const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
const vtkm::Vec<vtkm::Float32, 3>& lookAt)
: ColorMap(colorMap.PrepareForInput(Device()))
, ColorMapSize(colorMapSize)
, LightPosition(lightPosition)
, CameraPosition(cameraPosition)
, LookAt(lookAt)
, BackgroundColor(backgroundColor)
{
//Set up some default lighting parameters for now
LightAbmient[0] = .5f;
......@@ -327,11 +324,6 @@ public:
if (hitIdx < 0)
{
color = BackgroundColor;
colors.Set(offset + 0, color[0]);
colors.Set(offset + 1, color[1]);
colors.Set(offset + 2, color[2]);
colors.Set(offset + 3, color[3]);
return;
}
......@@ -380,20 +372,15 @@ public:
template <typename Precision>
VTKM_CONT void run(Ray<Precision>& rays,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorMap,
const vtkm::rendering::raytracing::Camera& camera,
const vtkm::Vec<vtkm::Float32, 4> backgroundColor)
const vtkm::rendering::raytracing::Camera& camera)
{
// TODO: support light positions
vtkm::Vec<vtkm::Float32, 3> scale(5, 5, 5);
vtkm::Vec<vtkm::Float32, 3> lightPosition = camera.GetPosition() + scale * camera.GetUp();
const vtkm::Int32 colorMapSize = vtkm::Int32(colorMap.GetNumberOfValues());
vtkm::worklet::DispatcherMapField<MapScalarToColor, Device>(
MapScalarToColor(colorMap,
colorMapSize,
lightPosition,
camera.GetPosition(),
camera.GetLookAt(),
backgroundColor))
MapScalarToColor(
colorMap, colorMapSize, lightPosition, camera.GetPosition(), camera.GetLookAt()))
.Invoke(rays.HitIdx, rays.Scalar, rays.Normal, rays.Intersection, rays.Buffers.at(0).Buffer);
}
}; // class SurfaceColor
......@@ -404,11 +391,6 @@ RayTracer::RayTracer()
{
}
void RayTracer::SetBackgroundColor(const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
{
BackgroundColor = backgroundColor;
}
Camera& RayTracer::GetCamera()
{
return camera;
......@@ -526,7 +508,7 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays, Device)
// Calculate the color at the intersection point
detail::SurfaceColor<Device> surfaceColor;
surfaceColor.run(rays, ColorMap, camera, BackgroundColor);
surfaceColor.run(rays, ColorMap, camera);
time = timer.GetElapsedTime();
logger->AddLogData("shade", time);
......
......@@ -47,7 +47,6 @@ protected:
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>> ColorMap;
vtkm::Range ScalarRange;
vtkm::Bounds DataBounds;
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
template <typename Precision>
struct RenderFunctor;
......@@ -58,9 +57,6 @@ public:
VTKM_CONT
RayTracer();
VTKM_CONT
void SetBackgroundColor(const vtkm::Vec<vtkm::Float32, 4>& backgroundColor);
VTKM_CONT
Camera& GetCamera();
......
......@@ -874,12 +874,6 @@ void VolumeRendererStructured::SetSampleDistance(const vtkm::Float32& distance)
throw vtkm::cont::ErrorBadValue("Sample distance must be positive.");
SampleDistance = distance;
}
void VolumeRendererStructured::SetBackgroundColor(
const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
{
BackgroundColor = backgroundColor;
}
}
}
} //namespace vtkm::rendering::raytracing
......@@ -70,9 +70,6 @@ public:
VTKM_CONT
void SetSampleDistance(const vtkm::Float32& distance);
VTKM_CONT
void SetBackgroundColor(const vtkm::Vec<vtkm::Float32, 4>& backgroundColor);
protected:
template <typename Precision, typename Device>
VTKM_CONT void RenderOnDevice(vtkm::rendering::raytracing::Ray<Precision>& rays, Device);
......@@ -87,7 +84,6 @@ protected:
const vtkm::cont::Field* ScalarField;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>> ColorMap;
vtkm::Float32 SampleDistance;
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
vtkm::Range ScalarRange;
};
}
......
Supports Markdown
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