mirror of
https://github.com/blender/blender
synced 2026-10-25 03:07:01 +03:00
Based on the "Stochastic ray tracing of transparent 3D Gaussians" paper by Xin Sun et. al. The basic idea: perform stochastic intersection with the Gaussian splat based on its transparency. Gaussian splats are implemented as a dedicated primitive type, but it shares the same layout for position and radius as points, so a lot of existing functions (positions, attributes, etc) work for both points and splats. For the Embree and hardware intersection it is implemented as a custom primitive type. The choice of using bounding spheres mainly comes from a balance between performance and memory usage. More ideal would be to use OBB, but it is not supported for custom primitive types in Embree and GPU HW-RT on all backends. There is a known limitation that comes from the fact that the datasets are trained in sRGB space and Cycles work in Linear space: areas with low opacity and high radiance render noticeably differently from the ground-truth implementation. Ref #159470 Pull Request: https://projects.blender.org/blender/blender/pulls/163103
73 lines
2.3 KiB
C
73 lines
2.3 KiB
C
/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#pragma once
|
|
|
|
#include "kernel/globals.h"
|
|
|
|
#include "kernel/bvh/util.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
/* Motion Point Primitive
|
|
*
|
|
* These are stored as regular points, plus extra positions and radii at times
|
|
* other than the frame center. Computing the point at a given ray time is
|
|
* a matter of interpolation of the two steps between which the ray time lies.
|
|
*
|
|
* The extra points are stored as additional motion steps in ATTR_STD_POSITION.
|
|
*/
|
|
|
|
#ifdef __POINTCLOUD__
|
|
|
|
ccl_device_forceinline int motion_point_offset_for_step(const int num_verts,
|
|
const int num_steps,
|
|
int step)
|
|
{
|
|
const int center_step = (num_steps - 1) / 2;
|
|
if (step == center_step) {
|
|
/* Center step: first in the array. */
|
|
return 0;
|
|
}
|
|
/* Non-center step, stored after center with center index skipped. */
|
|
if (step < center_step) {
|
|
step++;
|
|
}
|
|
return step * num_verts;
|
|
}
|
|
|
|
ccl_device_inline float4 motion_point_for_step(
|
|
KernelGlobals kg, int offset, const int numverts, const int numsteps, int step, const int prim)
|
|
{
|
|
offset += motion_point_offset_for_step(numverts, numsteps, step);
|
|
return kernel_data_fetch(points, offset + prim);
|
|
}
|
|
|
|
/* return 2 point key locations */
|
|
ccl_device_inline float4 motion_point(KernelGlobals kg,
|
|
const int object,
|
|
const int prim,
|
|
const float time)
|
|
{
|
|
/* get motion info */
|
|
const int numsteps = kernel_data_fetch(objects, object).num_geom_steps;
|
|
const int numverts = kernel_data_fetch(objects, object).numverts;
|
|
|
|
/* figure out which steps we need to fetch and their interpolation factor */
|
|
const int maxstep = numsteps - 1;
|
|
const int step = min((int)(time * maxstep), maxstep - 1);
|
|
const float t = time * maxstep - step;
|
|
|
|
/* fetch key coordinates */
|
|
const int offset = kernel_data_fetch(objects, object).position_offset;
|
|
const float4 point = motion_point_for_step(kg, offset, numverts, numsteps, step, prim);
|
|
const float4 next_point = motion_point_for_step(kg, offset, numverts, numsteps, step + 1, prim);
|
|
|
|
/* interpolate between steps */
|
|
return (1.0f - t) * point + t * next_point;
|
|
}
|
|
|
|
#endif
|
|
|
|
CCL_NAMESPACE_END
|