Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2020-11-04 17:09:06 +0300
committerPatrick Mours <pmours@nvidia.com>2020-11-04 17:09:06 +0300
commitfd9124ed6b35fc3701ec3a4a9980c6eda5324fac (patch)
tree342a5b7542a017f1b9888cb333a16dc2e097d7a4 /intern/cycles/render/image_vdb.cpp
parent43ceb0f0475e7d9a4095ae0675dd976d03a83cfe (diff)
Fix Cycles volume render differences with NanoVDB when using linear sampling
The NanoVDB sampling implementation behaves different from dense texture sampling, so this adds a small offset to the voxel indices to correct for that. Also removes the need to modify the sampling coordinates by moving all the necessary transformations into the image transform. See also T81454.
Diffstat (limited to 'intern/cycles/render/image_vdb.cpp')
-rw-r--r--intern/cycles/render/image_vdb.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/intern/cycles/render/image_vdb.cpp b/intern/cycles/render/image_vdb.cpp
index fc2cfe9874e..016bbf7151d 100644
--- a/intern/cycles/render/image_vdb.cpp
+++ b/intern/cycles/render/image_vdb.cpp
@@ -144,8 +144,13 @@ bool VDBImageLoader::load_metadata(ImageMetaData &metadata)
}
}
+# ifdef WITH_NANOVDB
+ /* Add small offset for correct sampling between voxels. */
+ Transform texture_to_index = transform_translate(0.5f, 0.5f, 0.5f);
+# else
Transform texture_to_index = transform_translate(min.x(), min.y(), min.z()) *
transform_scale(dim.x(), dim.y(), dim.z());
+# endif
metadata.transform_3d = transform_inverse(index_to_object * texture_to_index);
metadata.use_transform_3d = true;
@@ -159,10 +164,10 @@ bool VDBImageLoader::load_metadata(ImageMetaData &metadata)
bool VDBImageLoader::load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool)
{
-#if defined(WITH_NANOVDB)
+#ifdef WITH_OPENVDB
+# ifdef WITH_NANOVDB
memcpy(pixels, nanogrid.data(), nanogrid.size());
- return true;
-#elif defined(WITH_OPENVDB)
+# else
if (grid->isType<openvdb::FloatGrid>()) {
openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::FloatGrid>(grid), dense);
@@ -202,7 +207,7 @@ bool VDBImageLoader::load_pixels(const ImageMetaData &, void *pixels, const size
openvdb::tools::Dense<float, openvdb::tools::LayoutXYZ> dense(bbox, (float *)pixels);
openvdb::tools::copyToDense(*openvdb::gridConstPtrCast<openvdb::MaskGrid>(grid), dense);
}
-
+# endif
return true;
#else
(void)pixels;