[Bf-blender-cvs] [c7e7038] openvdb: Use tri-linear ("box") interpolation for OpenVDB grids rather than nearest point sampling.
Lukas Tönne
noreply at git.blender.org
Wed Nov 16 17:07:42 CET 2016
Commit: c7e7038edce55fd66f9ef3919cdf531e62afe99d
Author: Lukas Tönne
Date: Wed Nov 16 17:05:04 2016 +0100
Branches: openvdb
https://developer.blender.org/rBc7e7038edce55fd66f9ef3919cdf531e62afe99d
Use tri-linear ("box") interpolation for OpenVDB grids rather than nearest point sampling.
Cycles shading options contain a setting for tri-cubic sampling as well, but this
is not supported in OpenVDB by default (only tri-quadratic). Cubic sampling appears
a bit pointless anyway, compared to the ability to add actual geometric detail.
===================================================================
M intern/cycles/kernel/geom/geom_volume.h
M intern/cycles/kernel/openvdb/vdb_thread.cpp
===================================================================
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h
index 351df44..28ea80f 100644
--- a/intern/cycles/kernel/geom/geom_volume.h
+++ b/intern/cycles/kernel/geom/geom_volume.h
@@ -86,7 +86,13 @@ ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd,
#if 1 /* XXX WITH_OPENVDB ? */
float3 P = ccl_fetch(sd, P);
- r = kernel_tex_voxel_float(desc.offset, P.x, P.y, P.z, OPENVDB_SAMPLE_POINT);
+ /* XXX OpenVDB does not support cubic interpolation (could use quadratic though) - lukas_t */
+#if 0
+ if(sd->flag & SD_VOLUME_CUBIC)
+ r = kernel_tex_voxel_float(desc.offset, P.x, P.y, P.z, ...)
+ else
+#endif
+ r = kernel_tex_voxel_float(desc.offset, P.x, P.y, P.z, OPENVDB_SAMPLE_BOX);
#else
float3 P = volume_normalized_position(kg, sd, ccl_fetch(sd, P));
if(sd->flag & SD_VOLUME_CUBIC)
diff --git a/intern/cycles/kernel/openvdb/vdb_thread.cpp b/intern/cycles/kernel/openvdb/vdb_thread.cpp
index 5a65dc9..57c57f9 100644
--- a/intern/cycles/kernel/openvdb/vdb_thread.cpp
+++ b/intern/cycles/kernel/openvdb/vdb_thread.cpp
@@ -146,10 +146,14 @@ float vdb_volume_sample_scalar(OpenVDBGlobals */*vdb*/, OpenVDBThreadData *vdb_t
{
OpenVDBScalarThreadData &data = vdb_thread->scalar_data[vdb_index];
- if (sampling == OPENVDB_SAMPLE_POINT)
- return data.point_sampler->wsSample(openvdb::Vec3d(x, y, z));
- else
- return data.box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ switch (sampling) {
+ case OPENVDB_SAMPLE_POINT:
+ return data.point_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ case OPENVDB_SAMPLE_BOX:
+ return data.box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ }
+
+ return 0.0f;
}
float3 vdb_volume_sample_vector(OpenVDBGlobals *vdb, OpenVDBThreadData *vdb_thread, int vdb_index,
@@ -160,16 +164,24 @@ float3 vdb_volume_sample_vector(OpenVDBGlobals *vdb, OpenVDBThreadData *vdb_thre
openvdb::Vec3s r;
if (staggered) {
- if (sampling == OPENVDB_SAMPLE_POINT)
- r = data.stag_point_sampler->wsSample(openvdb::Vec3d(x, y, z));
- else
- r = data.stag_box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ switch (sampling) {
+ case OPENVDB_SAMPLE_POINT:
+ r = data.stag_point_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ break;
+ case OPENVDB_SAMPLE_BOX:
+ r = data.stag_box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ break;
+ }
}
else {
- if (sampling == OPENVDB_SAMPLE_POINT)
- r = data.point_sampler->wsSample(openvdb::Vec3d(x, y, z));
- else
- r = data.box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ switch (sampling) {
+ case OPENVDB_SAMPLE_POINT:
+ r = data.point_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ break;
+ case OPENVDB_SAMPLE_BOX:
+ r = data.box_sampler->wsSample(openvdb::Vec3d(x, y, z));
+ break;
+ }
}
return make_float3(r.x(), r.y(), r.z());
More information about the Bf-blender-cvs
mailing list