diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2016-11-16 19:05:04 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2016-11-16 19:05:04 +0300 |
commit | c7e7038edce55fd66f9ef3919cdf531e62afe99d (patch) | |
tree | f629e28156f6bb68a08f886d15fa953d2315c81a | |
parent | d30baf60c662915772e7952c1b715c461cb979ff (diff) |
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.
-rw-r--r-- | intern/cycles/kernel/geom/geom_volume.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/openvdb/vdb_thread.cpp | 36 |
2 files changed, 31 insertions, 13 deletions
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h index 351df44e561..28ea80f1a65 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 5a65dc94737..57c57f96f0f 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()); |