Commit 1c2f78ca authored by Matt Larsen's avatar Matt Larsen

refactoring ray tracing

parent bc977202
......@@ -28,9 +28,10 @@
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/rendering/Camera.h>
#include <vtkm/rendering/internal/RunTriangulator.h>
#include <vtkm/rendering/raytracing/Ray.h>
#include <vtkm/rendering/raytracing/RayTracer.h>
#include <vtkm/rendering/raytracing/SphereIntersector.h>
#include <vtkm/rendering/raytracing/TriangleExtractor.h>
#include <vtkm/exec/FunctorBase.h>
......@@ -66,18 +67,24 @@ struct BenchRayTracing
camera.ResetToBounds(bounds);
vtkm::cont::DynamicCellSet cellset = Data.GetCellSet();
vtkm::rendering::internal::RunTriangulator(cellset, Indices, NumberOfTriangles);
vtkm::rendering::raytracing::TriangleExtractor triExtractor;
triExtractor.ExtractCells(cellset);
vtkm::rendering::raytracing::TriangleIntersector* triIntersector =
new vtkm::rendering::raytracing::TriangleIntersector();
triIntersector->SetData(Coords, triExtractor.GetTriangles());
Tracer.AddShapeIntersector(triIntersector);
vtkm::rendering::CanvasRayTracer canvas(1920, 1080);
RayCamera.SetParameters(camera, canvas);
RayCamera.CreateRays(Rays, Coords);
RayCamera.CreateRays(Rays, Coords.GetBounds());
Rays.Buffers.at(0).InitConst(0.f);
vtkm::cont::Field field = Data.GetField("pointvar");
vtkm::Range range = field.GetRange().GetPortalConstControl().Get(0);
Tracer.SetData(Coords.GetData(), Indices, field, NumberOfTriangles, range, bounds);
Tracer.SetField(field, range);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> temp;
vtkm::cont::ColorTable table("cool to warm");
......@@ -107,7 +114,7 @@ struct BenchRayTracing
{
vtkm::cont::Timer<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> timer;
RayCamera.CreateRays(Rays, Coords);
RayCamera.CreateRays(Rays, Coords.GetBounds());
Tracer.Render(Rays);
return timer.GetElapsedTime();
......
This diff is collapsed.
......@@ -59,15 +59,20 @@ set(headers
ColorBarAnnotation.h
ColorLegendAnnotation.h
ConnectivityProxy.h
Cylinderizer.h
DecodePNG.h
LineRenderer.h
MatrixHelpers.h
Scene.h
Mapper.h
MapperCylinder.h
MapperPoint.h
MapperQuad.h
MapperRayTracer.h
MapperVolume.h
MapperConnectivity.h
MapperWireframer.h
Quadralizer.h
TextAnnotation.h
TextAnnotationBillboard.h
TextAnnotationScreen.h
......@@ -96,8 +101,12 @@ set(sources
DecodePNG.cxx
LineRenderer.cxx
MapperConnectivity.cxx
MapperCylinder.cxx
MapperPoint.cxx
MapperQuad.cxx
MapperRayTracer.cxx
MapperVolume.cxx
#MapperWireframer.cxx
Scene.cxx
TextAnnotation.cxx
TextAnnotationBillboard.cxx
......@@ -107,10 +116,6 @@ set(sources
View2D.cxx
View3D.cxx
WorldAnnotator.cxx
raytracing/ConnectivityBase.cxx
raytracing/ConnectivityTracerBase.cxx
raytracing/ConnectivityTracerFactory.cxx
raytracing/Logger.cxx
)
......@@ -161,8 +166,18 @@ set(device_sources
raytracing/Camera.cxx
raytracing/ChannelBuffer.cxx
raytracing/ConnectivityTracer.cxx
raytracing/RayOperations.cxx
raytracing/CylinderExtractor.cxx
raytracing/CylinderIntersector.cxx
raytracing/MeshConnectivityBuilder.cxx
raytracing/MeshConnectivityContainers.cxx
raytracing/QuadExtractor.cxx
raytracing/QuadIntersector.cxx
raytracing/RayTracer.cxx
raytracing/RayOperations.cxx
raytracing/ShapeIntersector.cxx
raytracing/SphereExtractor.cxx
raytracing/SphereIntersector.cxx
raytracing/TriangleExtractor.cxx
raytracing/VolumeRendererStructured.cxx
)
......
......@@ -313,8 +313,11 @@ void Canvas::Activate()
void Canvas::Clear()
{
vtkm::worklet::DispatcherMapField<internal::ClearBuffers>().Invoke(this->GetColorBuffer(),
this->GetDepthBuffer());
// TODO: Should the rendering library support policies or some other way to
// configure with custom devices?
internal::ClearBuffers worklet;
vtkm::worklet::DispatcherMapField<internal::ClearBuffers> dispatcher(worklet);
dispatcher.Invoke(this->GetColorBuffer(), this->GetDepthBuffer());
}
void Canvas::Finish()
......@@ -323,9 +326,9 @@ void Canvas::Finish()
void Canvas::BlendBackground()
{
vtkm::worklet::DispatcherMapField<internal::BlendBackground>(
this->GetBackgroundColor().Components)
.Invoke(this->GetColorBuffer());
internal::BlendBackground worklet(GetBackgroundColor().Components);
vtkm::worklet::DispatcherMapField<internal::BlendBackground> dispatcher(worklet);
dispatcher.Invoke(this->GetColorBuffer());
}
void Canvas::ResizeBuffers(vtkm::Id width, vtkm::Id height)
......
......@@ -21,7 +21,7 @@
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/ConnectivityProxy.h>
#include <vtkm/rendering/Mapper.h>
#include <vtkm/rendering/raytracing/ConnectivityTracerFactory.h>
#include <vtkm/rendering/raytracing/ConnectivityTracer.h>
#include <vtkm/rendering/raytracing/Logger.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
......@@ -34,9 +34,9 @@ struct ConnectivityProxy::InternalsType
{
protected:
using ColorMapType = vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>;
using BaseType = vtkm::rendering::raytracing::ConnectivityBase;
using TracerType = vtkm::rendering::raytracing::ConnectivityTracer;
BaseType* Tracer;
TracerType Tracer;
vtkm::cont::Field ScalarField;
vtkm::cont::Field EmissionField;
vtkm::cont::DynamicCellSet Cells;
......@@ -48,29 +48,6 @@ protected:
vtkm::Range ScalarRange;
bool CompositeBackground;
struct BoundsFunctor
{
vtkm::rendering::ConnectivityProxy::InternalsType* Internals;
const vtkm::cont::CoordinateSystem& Coordinates;
VTKM_CONT
BoundsFunctor(vtkm::rendering::ConnectivityProxy::InternalsType* self,
const vtkm::cont::CoordinateSystem& coordinates)
: Internals(self)
, Coordinates(coordinates)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
Internals->SpatialBounds = Internals->Coords.GetBounds();
return true;
}
};
public:
InternalsType(vtkm::cont::DataSet& dataSet)
{
......@@ -87,11 +64,9 @@ public:
{
this->SetScalarField(Dataset.GetField(0).GetName());
}
Tracer = raytracing::ConnectivityTracerFactory::CreateTracer(Cells, Coords);
}
~InternalsType() { delete Tracer; }
~InternalsType() {}
void SetSampleDistance(const vtkm::Float32& distance)
{
......@@ -100,7 +75,7 @@ public:
std::cout << "Volume Tracer Error: must set volume mode before setting sample dist\n";
return;
}
Tracer->SetSampleDistance(distance);
Tracer.SetSampleDistance(distance);
}
VTKM_CONT
......@@ -120,14 +95,14 @@ public:
VTKM_CONT
void SetColorMap(vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colormap)
{
Tracer->SetColorMap(colormap);
Tracer.SetColorMap(colormap);
}
VTKM_CONT
void SetCompositeBackground(bool on) { CompositeBackground = on; }
VTKM_CONT
void SetDebugPrints(bool on) { Tracer->SetDebugOn(on); }
void SetDebugPrints(bool vtkmNotUsed(on)) { /*Tracer->SetDebugOn(on);*/}
VTKM_CONT
void SetEmissionField(const std::string& fieldName)
......@@ -155,15 +130,18 @@ public:
if (Mode == VOLUME_MODE)
{
Tracer->SetVolumeData(this->ScalarField, this->ScalarRange);
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
}
else
{
Tracer->SetEnergyData(
this->ScalarField, rays.Buffers.at(0).GetNumChannels(), this->EmissionField);
Tracer.SetEnergyData(this->ScalarField,
rays.Buffers.at(0).GetNumChannels(),
this->Cells,
this->Coords,
this->EmissionField);
}
Tracer->Trace(rays);
Tracer.Trace(rays);
}
VTKM_CONT
......@@ -171,14 +149,18 @@ public:
{
if (Mode == VOLUME_MODE)
{
Tracer->SetVolumeData(this->ScalarField, this->ScalarRange);
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
}
else
{
Tracer->SetEnergyData(
this->ScalarField, rays.Buffers.at(0).GetNumChannels(), this->EmissionField);
Tracer.SetEnergyData(this->ScalarField,
rays.Buffers.at(0).GetNumChannels(),
this->Cells,
this->Coords,
this->EmissionField);
}
Tracer->Trace(rays);
Tracer.Trace(rays);
}
VTKM_CONT
......@@ -193,20 +175,20 @@ public:
vtkm::rendering::raytracing::Camera rayCamera;
rayCamera.SetParameters(camera, *canvas);
vtkm::rendering::raytracing::Ray<vtkm::Float32> rays;
rayCamera.CreateRays(rays, this->Coords);
rayCamera.CreateRays(rays, this->Coords.GetBounds());
rays.Buffers.at(0).InitConst(0.f);
raytracing::RayOperations::MapCanvasToRays(rays, camera, *canvas);
if (Mode == VOLUME_MODE)
{
Tracer->SetVolumeData(this->ScalarField, this->ScalarRange);
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
}
else
{
throw vtkm::cont::ErrorBadValue("ENERGY MODE Not implemented for this use case\n");
}
Tracer->Trace(rays);
Tracer.Trace(rays);
canvas->WriteToCanvas(rays, rays.Buffers.at(0).Buffer, camera);
if (CompositeBackground)
......
......@@ -24,10 +24,8 @@
#include <vtkm/rendering/MapperConnectivity.h>
#include <vtkm/rendering/View.h>
#include <vtkm/rendering/raytracing/Camera.h>
#include <vtkm/rendering/raytracing/ConnectivityTracerFactory.h>
#include <cstdlib>
#include <vtkm/rendering/raytracing/Camera.h>
namespace vtkm
{
......
......@@ -29,6 +29,9 @@
#include <vtkm/rendering/raytracing/Logger.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
#include <vtkm/rendering/raytracing/RayTracer.h>
#include <vtkm/rendering/raytracing/SphereExtractor.h>
#include <vtkm/rendering/raytracing/SphereIntersector.h>
#include <vtkm/rendering/raytracing/TriangleExtractor.h>
namespace vtkm
{
......@@ -91,25 +94,38 @@ void MapperRayTracer::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
logger->OpenLogEntry("mapper_ray_tracer");
vtkm::cont::Timer<> tot_timer;
vtkm::cont::Timer<> timer;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> indices;
vtkm::Id numberOfTriangles;
vtkm::rendering::internal::RunTriangulator(cellset, indices, numberOfTriangles);
vtkm::Float64 time = timer.GetElapsedTime();
logger->AddLogData("triangulator", time);
// make sure we start fresh
this->Internals->Tracer.Clear();
//
// Add supported shapes
//
vtkm::Bounds shapeBounds;
raytracing::TriangleExtractor triExtractor;
triExtractor.ExtractCells(cellset);
if (triExtractor.GetNumberOfTriangles() > 0)
{
raytracing::TriangleIntersector* triIntersector = new raytracing::TriangleIntersector();
triIntersector->SetData(coords, triExtractor.GetTriangles());
this->Internals->Tracer.AddShapeIntersector(triIntersector);
shapeBounds.Include(triIntersector->GetShapeBounds());
}
//
// Create rays
//
vtkm::rendering::raytracing::Camera& cam = this->Internals->Tracer.GetCamera();
cam.SetParameters(camera, *this->Internals->Canvas);
this->Internals->RayCamera.SetParameters(camera, *this->Internals->Canvas);
this->Internals->RayCamera.CreateRays(this->Internals->Rays, coords);
this->Internals->RayCamera.CreateRays(this->Internals->Rays, shapeBounds);
this->Internals->Rays.Buffers.at(0).InitConst(0.f);
raytracing::RayOperations::MapCanvasToRays(
this->Internals->Rays, camera, *this->Internals->Canvas);
vtkm::Bounds dataBounds = coords.GetBounds();
vtkm::cont::Field& field = const_cast<vtkm::cont::Field&>(scalarField);
this->Internals->Tracer.SetData(
coords.GetData(), indices, field, numberOfTriangles, scalarRange, dataBounds);
this->Internals->Tracer.SetField(scalarField, scalarRange);
this->Internals->Tracer.SetColorMap(this->ColorMap);
this->Internals->Tracer.Render(this->Internals->Rays);
......@@ -123,7 +139,7 @@ void MapperRayTracer::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
this->Internals->Canvas->BlendBackground();
}
time = timer.GetElapsedTime();
vtkm::Float64 time = timer.GetElapsedTime();
logger->AddLogData("write_to_canvas", time);
time = tot_timer.GetElapsedTime();
logger->CloseLogEntry(time);
......
......@@ -114,7 +114,7 @@ void MapperVolume::RenderCells(const vtkm::cont::DynamicCellSet& cellset,
rayCamera.SetParameters(camera, *this->Internals->Canvas);
rayCamera.CreateRays(rays, coords);
rayCamera.CreateRays(rays, coords.GetBounds());
rays.Buffers.at(0).InitConst(0.f);
raytracing::RayOperations::MapCanvasToRays(rays, camera, *this->Internals->Canvas);
......
......@@ -21,7 +21,7 @@
#ifndef vtk_m_rendering_Texture2D_h
#define vtk_m_rendering_Texture2D_h
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
......@@ -77,7 +77,7 @@ public:
// We do not know the lifetime of the underlying data source of input `data`. Since it might
// be from a shallow copy of the data source, we make a deep copy of the input data and keep
// it's portal. The copy operation is very fast.
vtkm::cont::ArrayCopy(data, Data);
vtkm::cont::Algorithm::Copy(data, Data);
}
VTKM_CONT
......
This diff is collapsed.
......@@ -496,10 +496,8 @@ private:
if (ShowInternalZones && !IsOverlay)
{
using MemSet =
typename vtkm::rendering::Triangulator<DeviceTag>::template MemSet<vtkm::Int64>;
MemSet memSet(ClearValue);
vtkm::worklet::DispatcherMapField<MemSet>(memSet).Invoke(FrameBuffer);
vtkm::cont::ArrayHandleConstant<vtkm::Int64> clear(ClearValue, pixelCount);
vtkm::cont::Algorithm::Copy(clear, FrameBuffer);
}
else
{
......
......@@ -30,47 +30,12 @@ namespace rendering
namespace internal
{
namespace
{
struct TriangulatorFunctor
{
vtkm::cont::DynamicCellSet CellSet;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> Indices;
vtkm::Id NumberOfTriangles;
VTKM_CONT
TriangulatorFunctor(vtkm::cont::DynamicCellSet cellSet)
: CellSet(cellSet)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device)
{
vtkm::rendering::Triangulator<Device> triangulator;
triangulator.Run(this->CellSet, this->Indices, this->NumberOfTriangles);
return true;
}
};
} // anonymous namespace
void RunTriangulator(const vtkm::cont::DynamicCellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>>& indices,
vtkm::Id& numberOfTriangles,
vtkm::cont::RuntimeDeviceTracker tracker)
vtkm::Id& numberOfTriangles)
{
// TODO: Should the rendering library support policies or some other way to
// configure with custom devices?
TriangulatorFunctor triangulatorFunctor(cellSet);
if (!vtkm::cont::TryExecute(triangulatorFunctor, tracker))
{
throw vtkm::cont::ErrorExecution("Failed to execute triangulator.");
}
indices = triangulatorFunctor.Indices;
numberOfTriangles = triangulatorFunctor.NumberOfTriangles;
vtkm::rendering::Triangulator triangulator;
triangulator.Run(cellSet, indices, numberOfTriangles);
}
}
}
......
......@@ -39,11 +39,9 @@ namespace internal
/// filters, and filters should be compiled in a library (for the same reason).
///
VTKM_RENDERING_EXPORT
void RunTriangulator(
const vtkm::cont::DynamicCellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>>& indices,
vtkm::Id& numberOfTriangles,
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker());
void RunTriangulator(const vtkm::cont::DynamicCellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>>& indices,
vtkm::Id& numberOfTriangles);
}
}
} // namespace vtkm::rendering::internal
......
......@@ -31,6 +31,16 @@ namespace rendering
namespace raytracing
{
struct AABBs
{
vtkm::cont::ArrayHandle<vtkm::Float32> xmins;
vtkm::cont::ArrayHandle<vtkm::Float32> ymins;
vtkm::cont::ArrayHandle<vtkm::Float32> zmins;
vtkm::cont::ArrayHandle<vtkm::Float32> xmaxs;
vtkm::cont::ArrayHandle<vtkm::Float32> ymaxs;
vtkm::cont::ArrayHandle<vtkm::Float32> zmaxs;
};
//
// This is the data structure that is passed to the ray tracer.
//
......@@ -38,16 +48,15 @@ class VTKM_RENDERING_EXPORT LinearBVH
{
public:
using InnerNodesHandle = vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>;
using LeafNodesHandle = vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Int32, 4>>;
using LeafNodesHandle = vtkm::cont::ArrayHandle<Id>;
AABBs AABB;
InnerNodesHandle FlatBVH;
LeafNodesHandle LeafNodes;
LeafNodesHandle Leafs;
vtkm::Bounds TotalBounds;
struct ConstructFunctor;
vtkm::Id LeafCount;
vtkm::Bounds CoordBounds;
protected:
vtkm::cont::ArrayHandleVirtualCoordinates CoordsHandle;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> Triangles;
bool IsConstructed;
bool CanConstruct;
......@@ -55,9 +64,7 @@ public:
LinearBVH();
VTKM_CONT
LinearBVH(vtkm::cont::ArrayHandleVirtualCoordinates coordsHandle,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> triangles,
vtkm::Bounds coordBounds);
LinearBVH(AABBs& aabbs);
VTKM_CONT
LinearBVH(const LinearBVH& other);
......@@ -69,9 +76,10 @@ public:
void Construct();
VTKM_CONT
void SetData(vtkm::cont::ArrayHandleVirtualCoordinates coordsHandle,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> triangles,
vtkm::Bounds coordBounds);
void SetData(AABBs& aabbs);
VTKM_CONT
AABBs& GetAABBs();
template <typename Device>
VTKM_CONT void ConstructOnDevice(Device device);
......@@ -79,13 +87,7 @@ public:
VTKM_CONT
bool GetIsConstructed() const;
VTKM_CONT
vtkm::cont::ArrayHandleVirtualCoordinates GetCoordsHandle() const;
VTKM_CONT
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 4>> GetTriangles() const;
vtkm::Id GetNumberOfTriangles() const;
vtkm::Id GetNumberOfAABBs() const;
}; // class LinearBVH
}
}
......
......@@ -20,24 +20,32 @@
set(headers
BoundingVolumeHierarchy.h
BVHTraverser.h
Camera.h
CellIntersector.h
CellSampler.h
CellTables.h
ChannelBuffer.h
ChannelBufferOperations.h
ConnectivityBase.h
ConnectivityTracer.h
ConnectivityTracerBase.h
ConnectivityTracerFactory.h
CylinderExtractor.h
CylinderIntersector.h
Logger.h
MeshConnectivityBuilder.h
MeshConnectivityStructures.h
MeshConnectivityContainers.h
MeshConnectivityBase.h
MortonCodes.h
QuadExtractor.h
QuadIntersector.h
Ray.h
RayOperations.h
RayTracer.h
RayTracingTypeDefs.h
Sampler.h
ShapeIntersector.h
SphereExtractor.h
SphereIntersector.h
TriangleExtractor.h
TriangleIntersector.h
VolumeRendererStructured.h
Worklets.h
......
......@@ -29,6 +29,7 @@
#include <vtkm/rendering/raytracing/Logger.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
#include <vtkm/rendering/raytracing/RayTracingTypeDefs.h>
#include <vtkm/rendering/raytracing/Sampler.h>
#include <vtkm/rendering/raytracing/Worklets.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -162,6 +163,82 @@ public:
}; // class pixelData
class PerspectiveRayGenJitter : public vtkm::worklet::WorkletMapField
{
public:
vtkm::Int32 w;
vtkm::Int32 h;
vtkm::Vec<vtkm::Float32, 3> nlook; // normalized look
vtkm::Vec<vtkm::Float32, 3> delta_x;
vtkm::Vec<vtkm::Float32, 3> delta_y;
vtkm::Int32 CurrentSample;
VTKM_CONT_EXPORT
PerspectiveRayGenJitter(vtkm::Int32 width,
vtkm::Int32 height,
vtkm::Float32 fovX,
vtkm::Float32 fovY,
vtkm::Vec<vtkm::Float32, 3> look,
vtkm::Vec<vtkm::Float32, 3> up,
vtkm::Float32 _zoom,
vtkm::Int32 currentSample)
: w(width)
, h(height)
{
vtkm::Float32 thx = tanf((fovX * 3.1415926f / 180.f) * .5f);
vtkm::Float32 thy = tanf((fovY * 3.1415926f / 180.f) * .5f);
vtkm::Vec<vtkm::Float32, 3> ru = vtkm::Cross(up, look);
vtkm::Normalize(ru);
vtkm::Vec<vtkm::Float32, 3> rv = vtkm::Cross(ru, look);
vtkm::Normalize(rv);
delta_x = ru * (2 * thx / (float)w);
delta_y = rv * (2 * thy / (float)h);
if (_zoom > 0)
{
delta_x[0] = delta_x[0] / _zoom;
delta_x[1] = delta_x[1] / _zoom;
delta_x[2] = delta_x[2] / _zoom;
delta_y[0] = delta_y[0] / _zoom;
delta_y[1] = delta_y[1] / _zoom;
delta_y[2] = delta_y[2] / _zoom;
}
nlook = look;
vtkm::Normalize(nlook);
CurrentSample = currentSample;
}
typedef void ControlSignature(FieldOut<>, FieldOut<>, FieldOut<>, FieldIn<>);
typedef void ExecutionSignature(WorkIndex, _1, _2, _3, _4);
VTKM_EXEC
void operator()(vtkm::Id idx,
vtkm::Float32& rayDirX,
vtkm::Float32& rayDirY,
vtkm::Float32& rayDirZ,
const vtkm::Int32& seed) const
{
vtkm::Vec<vtkm::Float32, 2> xy;
Halton2D<3>(CurrentSample + seed, xy);
xy[0] -= .5f;
xy[1] -= .5f;
vtkm::Vec<vtkm::Float32, 3> ray_dir(rayDirX, rayDirY, rayDirZ);
vtkm::Float32 i = static_cast<vtkm::Float32>(vtkm::Int32(idx) % w);
vtkm::Float32 j = static_cast<vtkm::Float32>(vtkm::Int32(idx) / w);
i += xy[0];
j += xy[1];
ray_dir = nlook + delta_x * ((2.f * i - vtkm::Float32(w)) / 2.0f) +
delta_y * ((2.f * j - vtkm::Float32(h)) / 2.0f);
vtkm::Normalize(ray_dir);
rayDirX = ray_dir[0];
rayDirY = ray_dir[1];
rayDirZ = ray_dir[2];
}
}; // class perspective ray gen jitter
class Camera::Ortho2DRayGen : public vtkm::worklet::WorkletMapField
{
public:
......@@ -631,35 +708,6 @@ bool Camera::GetIsViewDirty() const
return this->IsViewDirty;
}
template <typename Precision>
struct Camera::CreateRaysFunctor
{
vtkm::rendering::raytracing::Camera* Self;
const vtkm::cont::CoordinateSystem& Coords;