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-21 17:37:38 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-07-25 14:27:40 +0300
commit484ad3165307391aa5c55656b876b3ff7d615e80 (patch)
treebec9ffec4502fb93981cfae7d8b7b82852c0233d /intern/cycles/kernel/geom/point_intersect.h
parent023eb2ea7c16a00272f83d564145e28aeb9ed2b7 (diff)
Cycles: simplify handling of ray distance in GPU rendering
All our intersections functions now work with unnormalized ray direction, which means we no longer need to transform ray distance between world and object space, they can all remain in world space. There doesn't seem to be any real performance difference one way or the other, but it does simplify the code.
Diffstat (limited to 'intern/cycles/kernel/geom/point_intersect.h')
-rw-r--r--intern/cycles/kernel/geom/point_intersect.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/intern/cycles/kernel/geom/point_intersect.h b/intern/cycles/kernel/geom/point_intersect.h
index ee5a564947b..15fb814c58d 100644
--- a/intern/cycles/kernel/geom/point_intersect.h
+++ b/intern/cycles/kernel/geom/point_intersect.h
@@ -10,20 +10,20 @@ CCL_NAMESPACE_BEGIN
#ifdef __POINTCLOUD__
ccl_device_forceinline bool point_intersect_test(const float4 point,
- const float3 P,
- const float3 dir,
- const float tmin,
- const float tmax,
+ const float3 ray_P,
+ const float3 ray_D,
+ const float ray_tmin,
+ const float ray_tmax,
ccl_private float *t)
{
const float3 center = float4_to_float3(point);
const float radius = point.w;
- const float rd2 = 1.0f / dot(dir, dir);
+ const float rd2 = 1.0f / dot(ray_D, ray_D);
- const float3 c0 = center - P;
- const float projC0 = dot(c0, dir) * rd2;
- const float3 perp = c0 - projC0 * dir;
+ const float3 c0 = center - ray_P;
+ const float projC0 = dot(c0, ray_D) * rd2;
+ const float3 perp = c0 - projC0 * ray_D;
const float l2 = dot(perp, perp);
const float r2 = radius * radius;
if (!(l2 <= r2)) {
@@ -32,12 +32,12 @@ ccl_device_forceinline bool point_intersect_test(const float4 point,
const float td = sqrt((r2 - l2) * rd2);
const float t_front = projC0 - td;
- const bool valid_front = (tmin <= t_front) & (t_front <= tmax);
+ const bool valid_front = (ray_tmin <= t_front) & (t_front <= ray_tmax);
/* Always back-face culling for now. */
# if 0
const float t_back = projC0 + td;
- const bool valid_back = (tmin <= t_back) & (t_back <= tmax);
+ const bool valid_back = (ray_tmin <= t_back) & (t_back <= ray_tmax);
/* check if there is a first hit */
const bool valid_first = valid_front | valid_back;
@@ -58,10 +58,10 @@ ccl_device_forceinline bool point_intersect_test(const float4 point,
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 float3 ray_P,
+ const float3 ray_D,
+ const float ray_tmin,
+ const float ray_tmax,
const int object,
const int prim,
const float time,
@@ -70,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, tmin, tmax, &isect->t)) {
+ if (!point_intersect_test(point, ray_P, ray_D, ray_tmin, ray_tmax, &isect->t)) {
return false;
}