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:
authorBrecht Van Lommel <brecht@blender.org>2022-07-13 17:54:53 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-07-15 19:46:24 +0300
commit5152c7c152e52d563cbd3ba3c792de3af0c2c14f (patch)
tree45cad004066413ce309279ad52f2a363e5477150 /intern/cycles/kernel/geom/point_intersect.h
parentbb376da6dfdd2476fc3738ce1fc89dac27825cef (diff)
Cycles: refactor rays to have start and end distance, fix precision issues
For transparency, volume and light intersection rays, adjust these distances rather than the ray start position. This way we increment the start distance by the smallest possible float increment to avoid self intersections, and be sure it works as the distance compared to be will be exactly the same as before, due to the ray start position and direction remaining the same. Fix T98764, T96537, hair ray tracing precision issues. Differential Revision: https://developer.blender.org/D15455
Diffstat (limited to 'intern/cycles/kernel/geom/point_intersect.h')
-rw-r--r--intern/cycles/kernel/geom/point_intersect.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/intern/cycles/kernel/geom/point_intersect.h b/intern/cycles/kernel/geom/point_intersect.h
index dfd9d9a015b..ee5a564947b 100644
--- a/intern/cycles/kernel/geom/point_intersect.h
+++ b/intern/cycles/kernel/geom/point_intersect.h
@@ -9,8 +9,12 @@ CCL_NAMESPACE_BEGIN
#ifdef __POINTCLOUD__
-ccl_device_forceinline bool point_intersect_test(
- const float4 point, const float3 P, const float3 dir, const float tmax, ccl_private float *t)
+ccl_device_forceinline bool point_intersect_test(const float4 point,
+ const float3 P,
+ const float3 dir,
+ const float tmin,
+ const float tmax,
+ ccl_private float *t)
{
const float3 center = float4_to_float3(point);
const float radius = point.w;
@@ -28,12 +32,12 @@ ccl_device_forceinline bool point_intersect_test(
const float td = sqrt((r2 - l2) * rd2);
const float t_front = projC0 - td;
- const bool valid_front = (0.0f <= t_front) & (t_front <= tmax);
+ const bool valid_front = (tmin <= t_front) & (t_front <= tmax);
/* Always back-face culling for now. */
# if 0
const float t_back = projC0 + td;
- const bool valid_back = (0.0f <= t_back) & (t_back <= tmax);
+ const bool valid_back = (tmin <= t_back) & (t_back <= tmax);
/* check if there is a first hit */
const bool valid_first = valid_front | valid_back;
@@ -56,6 +60,7 @@ ccl_device_forceinline bool point_intersect(KernelGlobals kg,
ccl_private Intersection *isect,
const float3 P,
const float3 dir,
+ const float tmin,
const float tmax,
const int object,
const int prim,
@@ -65,7 +70,7 @@ ccl_device_forceinline bool point_intersect(KernelGlobals kg,
const float4 point = (type & PRIMITIVE_MOTION) ? motion_point(kg, object, prim, time) :
kernel_data_fetch(points, prim);
- if (!point_intersect_test(point, P, dir, tmax, &isect->t)) {
+ if (!point_intersect_test(point, P, dir, tmin, tmax, &isect->t)) {
return false;
}