Skip to content

Commit

Permalink
Recognize parameter "filter" on some field types
Browse files Browse the repository at this point in the history
  • Loading branch information
szellmann committed Dec 10, 2024
1 parent f168376 commit 740de45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scene/volume/spatial_field/NanoVDBField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void NanoVDBField::commit()
return;
}

m_filter = getParamString("filter", "linear");

#ifdef WITH_CUDA
cudaStream_t stream; // TODO: move to global state/use the one there?!
cudaStreamCreate(&stream);
Expand All @@ -46,7 +48,7 @@ void NanoVDBField::commit()
vfield.asNanoVDB.grid = m_gridHandle.grid<float>();
#endif

vfield.asNanoVDB.filterMode = Linear;
vfield.asNanoVDB.filterMode = m_filter == "nearest" ? Nearest : Linear;

vfield.voxelSpaceTransform = mat4x3(mat3::identity(),float3{0.f,0.f,0.f});

Expand Down
2 changes: 2 additions & 0 deletions scene/volume/spatial_field/NanoVDBField.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct NanoVDBField : public SpatialField
void buildGrid() override;
private:

std::string m_filter;

helium::IntrusivePtr<Array1D> m_gridData;

#ifdef WITH_CUDA
Expand Down
3 changes: 2 additions & 1 deletion scene/volume/spatial_field/StructuredRegularField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void StructuredRegularField::commit()

m_origin = getParam<float3>("origin", float3(0.f));
m_spacing = getParam<float3>("spacing", float3(1.f));
m_filter = getParamString("filter", "linear");

mat3 S = mat3::scaling(1.f/bounds().size());
vec3 T = -bounds().min;
Expand Down Expand Up @@ -60,7 +61,7 @@ void StructuredRegularField::commit()
} else if (m_type == ANARI_FLOAT32)
tex.reset((float *)m_dataArray->data());

tex.set_filter_mode(Linear);
tex.set_filter_mode(m_filter == "nearest" ? Nearest : Linear);
tex.set_address_mode(Clamp);

#ifdef WITH_CUDA
Expand Down
1 change: 1 addition & 0 deletions scene/volume/spatial_field/StructuredRegularField.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct StructuredRegularField : public SpatialField
uint3 m_dims{0u};
float3 m_origin;
float3 m_spacing;
std::string m_filter;

helium::IntrusivePtr<Array3D> m_dataArray;

Expand Down

0 comments on commit 740de45

Please sign in to comment.