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:
authorLukas Stockner <lukas.stockner@freenet.de>2016-06-07 00:38:28 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2016-06-07 00:38:50 +0300
commit7a5a02509bcd6f5c0fdf2df9f06537cbfd76f027 (patch)
treea006585abf8baaaf8aa85e86fddfc85d3746e0ef /intern/cycles/kernel/kernel_light.h
parentac7feaed3d4d80c60557b3c4af5eee65bef2e4ec (diff)
Cycles: Use faster ray-quad-intersection test
The original quad intersection test works by just testing against the two triangles that define the quad. However, in this case it's actually faster to use the same test that's also used for portals: Determining the distance to the plane in which the quad lies, calculating the hitpoint and checking whether it's in the quad by projecting onto the sides. Reviewers: brecht, sergey, dingto Reviewed By: dingto Differential Revision: https://developer.blender.org/D2045
Diffstat (limited to 'intern/cycles/kernel/kernel_light.h')
-rw-r--r--intern/cycles/kernel/kernel_light.h17
1 files changed, 3 insertions, 14 deletions
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 675eacfc5ee..736a884f819 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -291,24 +291,13 @@ ccl_device float background_portal_pdf(KernelGlobals *kg,
}
num_possible++;
- float t = -(dot(P, dir) - dot(lightpos, dir)) / dot(direction, dir);
- if(t <= 1e-4f) {
- /* Either behind the portal or too close. */
- continue;
- }
-
float4 data1 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 1);
float4 data2 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 2);
float3 axisu = make_float3(data1.y, data1.z, data1.w);
float3 axisv = make_float3(data2.y, data2.z, data2.w);
- float3 hit = P + t*direction;
- float3 inplane = hit - lightpos;
- /* Skip if the the ray doesn't pass through portal. */
- if(fabsf(dot(inplane, axisu) / dot(axisu, axisu)) > 0.5f)
- continue;
- if(fabsf(dot(inplane, axisv) / dot(axisv, axisv)) > 0.5f)
+ if(!ray_quad_intersect(P, direction, 1e-4f, FLT_MAX, lightpos, axisu, axisv, dir, NULL, NULL))
continue;
portal_pdf += area_light_sample(P, &lightpos, axisu, axisv, 0.0f, 0.0f, false);
@@ -729,8 +718,8 @@ ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D,
float3 light_P = make_float3(data0.y, data0.z, data0.w);
- if(!ray_quad_intersect(P, D, t,
- light_P, axisu, axisv, &ls->P, &ls->t))
+ if(!ray_quad_intersect(P, D, 0.0f, t,
+ light_P, axisu, axisv, Ng, &ls->P, &ls->t))
{
return false;
}