Skip to content

Commit

Permalink
update before push to branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolemarsaglia committed Nov 15, 2024
1 parent 9b270a8 commit 59f6bbf
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 10 deletions.
29 changes: 29 additions & 0 deletions src/config/ascent_setup_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,35 @@ if(KOKKOS_DIR)
PATHS ${KOKKOS_CMAKE_CONFIG_DIR})
endif()

###############################################################################
# Setup ANARI
###############################################################################
if(NOT ANARI_DIR)
set(ANARI_DIR ${ASCENT_ANARI_DIR})
endif()

if(EXISTS ${ANARI_DIR}/lib64/cmake/Kokkos/)
set(ANARI_CMAKE_CONFIG_DIR ${ANARI_DIR}/lib64/cmake/anari/)
endif()

if(EXISTS ${ANARI_DIR}/lib/cmake/Kokkos/)
set(ANARI_CMAKE_CONFIG_DIR ${ANARI_DIR}/lib/cmake/anari/)
endif()


if(ANARI_DIR)
if(NOT EXISTS ${ANARI_CMAKE_CONFIG_DIR}/anariConfig.cmake)
MESSAGE(FATAL_ERROR "Could not find ANARI CMake include file (${ANARI_CMAKE_CONFIG_DIR}/anariConfig.cmake)")
endif()

###############################################################################
# Import CMake targets
###############################################################################
find_dependency(anari REQUIRED
NO_DEFAULT_PATH
PATHS ${ANARI_CMAKE_CONFIG_DIR})
endif()

###############################################################################
# Setup VTK-m
###############################################################################
Expand Down
58 changes: 50 additions & 8 deletions src/libs/vtkh/rendering/ANARIVolumeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,33 @@ anari_device_load()

void
set_tfn(vtkm::interop::anari::ANARIMapper& mapper,
anari_cpp::Device& device,
vtkm::cont::ColorTable& color_table,
anari_cpp::Device& device,
vtkm::cont::ColorTable& color_table,
vtkm::Range& scalar_range)
{
//auto colorArray = anari_cpp::newArray1D(device, ANARI_FLOAT32_VEC3, 3);
//auto* colors = anari_cpp::map<vtkm::Vec3f_32>(device, colorArray);
//colors[0] = vtkm::Vec3f_32(0.f, 0.f, 1.f);
//colors[1] = vtkm::Vec3f_32(0.f, 1.f, 0.f);
//colors[2] = vtkm::Vec3f_32(1.f, 0.f, 0.f);
//anari_cpp::unmap(device, colorArray);

//auto opacityArray = anari_cpp::newArray1D(device, ANARI_FLOAT32, 2);
//auto* opacities = anari_cpp::map<float>(device, opacityArray);
//opacities[0] = 0.f;
//opacities[1] = 1.f;
//anari_cpp::unmap(device, opacityArray);

//mapper.SetColorTable(color_table);
//mapper.SetANARIColorMap(colorArray, opacityArray, true);
//mapper.SetANARIColorMapValueRange(vtkm::Vec2f_32(0.f, 10.f));
//mapper.SetANARIColorMapOpacityScale(0.5f);

constexpr int resolution = 256;

constexpr vtkm::Float32 conversionToFloatSpace = (1.0f / 255.0f);
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> temp;
{
vtkm::cont::ScopedRuntimeDeviceTracker tracker(vtkm::cont::DeviceAdapterTagSerial{});
color_table.Sample(resolution, temp);
}
auto colorPortal = temp.ReadPortal();
Expand Down Expand Up @@ -202,8 +219,8 @@ ANARIVolumeRenderer::ANARIVolumeRenderer()
////
//// add some default opacity to the color table
////
//m_color_table.AddPointAlpha(0.0f, .02);
//m_color_table.AddPointAlpha(.0f, .5);
m_color_table.AddPointAlpha(0.0f, .02);
m_color_table.AddPointAlpha(.0f, .5);
m_num_samples = 100.f;
//m_has_unstructured = false;
}
Expand Down Expand Up @@ -276,8 +293,29 @@ ANARIVolumeRenderer::DoExecute()
std::cerr << "HERE DoExecute 1" << std::endl;
// Build Scene
vtkm::interop::anari::ANARIScene scene(m_device);
std::cerr << "INPUT in ANARI: " << std::endl;
m_input->PrintSummary(std::cerr);
for (int i = 0; i < m_input->GetNumberOfDomains(); ++i)
{
//std::cerr << "CELLSET: " << std::endl;
//m_input->GetDomain(i).GetCellSet().PrintSummary(std::cerr);
//std::cerr << "COORDSET: " << std::endl;
//m_input->GetDomain(i).GetCoordinateSystem().PrintSummary(std::cerr);
//std::cerr << "FIELD: " << std::endl;
//m_input->GetDomain(i).GetField(m_field_name).PrintSummary(std::cerr);
if(m_input->IsUnstructured())
{
auto& mIso = scene.AddMapper(vtkm::interop::anari::ANARIMapperTriangles(m_device));
mIso.SetName(("isosurface_" + std::to_string(i)).c_str());
mIso.SetActor({
m_input->GetDomain(i).GetCellSet(),
m_input->GetDomain(i).GetCoordinateSystem(),
m_input->GetDomain(i).GetField(m_field_name)
});
mIso.SetCalculateNormals(true);
detail::set_tfn(mIso,m_device,m_color_table,m_range);
}

auto& mVol = scene.AddMapper(vtkm::interop::anari::ANARIMapperVolume(m_device));
mVol.SetName(("volume_" + std::to_string(i)).c_str());
mVol.SetActor({
Expand All @@ -301,11 +339,14 @@ ANARIVolumeRenderer::DoExecute()
std::string img_name = m_renders[i].GetImageName();
vtkm::Float32 height = m_renders[i].GetHeight();
vtkm::Float32 width = m_renders[i].GetWidth();
std::cerr <<"m_field_name: " << m_field_name << std::endl;
std::cerr <<"img_name: " << img_name << std::endl;
std::cerr << "width and height: " << width << " " << height << std::endl;
// Finalize
//render(scene);
// m_renderer parameters
std::cerr << "set anari parameters" << std::endl;
std::cerr << "m_num_samples"<< m_num_samples << std::endl;
anari_cpp::setParameter(m_device, m_renderer, "background", background);
anari_cpp::setParameter(m_device, m_renderer, "pixelSamples", m_num_samples);
anari_cpp::setParameter(m_device, m_renderer, "ambientRadiance", 0.8f);
Expand Down Expand Up @@ -389,7 +430,7 @@ std::cerr <<" anari colors and depth" << std::endl;
for(int pixel = 0; pixel < size; ++pixel)
{
int color_index = pixel*4;
std::cerr << "color index: " << color_index << std::endl;
//std::cerr << "color index: " << color_index << std::endl;
vtkm::Vec4f_32 color;
//color[0] = a_colors.data[color_index];
//color[1] = a_colors.data[color_index+1];
Expand All @@ -403,8 +444,9 @@ std::cerr <<" anari colors and depth" << std::endl;
//color.SetComponentFromByte(3, a_colors.data[color_index + 3]);
//std::cerr << "get depth" << std::endl;
vtkm::Float32 d = d_pixels[pixel];
std::cerr << "set depth: " << d << " at pixel: " << pixel << std::endl;
//v_depths.Set(pixel,d);
//if(d < 10000)
// std::cerr << "set depth: " << d << " at pixel: " << pixel << std::endl;
v_depths.Set(pixel,d);

}

Expand Down
8 changes: 8 additions & 0 deletions src/libs/vtkh/rendering/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ Scene::Render()

batch_start = batch_end;
} // while
std::cerr << "print ranges in SCENE" << std::endl;
std::cerr << "num ranges: " << ranges.size() << std::endl;
int num_r = ranges.size();
for(int i = 0; i < num_r; i++)
{
std::cerr <<"RANGE " << i << " min: " << ranges[i].Min << " max: " << ranges[i].Max << std::endl;

}
}

void Scene::SynchDepths(std::vector<vtkh::Render> &renders)
Expand Down
6 changes: 4 additions & 2 deletions src/tests/vtkh/t_vtk-h_anari_volume_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(vtkh_volume_renderer, vtkh_parallel_render_ustructured)
vtkh::DataSet data_set;

const int base_size = 32;
const int num_blocks = 2;
const int num_blocks = 1;

for(int i = 0; i < num_blocks; ++i)
{
Expand Down Expand Up @@ -110,7 +110,9 @@ TEST(vtkh_volume_renderer, vtkh_parallel_render)
vtkm::cont::ColorTable color_map("Cool to Warm");
color_map.AddPointAlpha(0.0, 0.01);
color_map.AddPointAlpha(1.0, 0.6);

std::cerr << "input data in UNIT TEST START " << std::endl;
data_set.PrintSummary(std::cerr);
std::cerr << "input data in UNIT TEST END " << std::endl;
vtkh::ANARIVolumeRenderer tracer;
tracer.SetColorTable(color_map);
tracer.SetInput(&data_set);
Expand Down

0 comments on commit 59f6bbf

Please sign in to comment.