From b54447c0eb12d78cd1282db4cb3fb49a9be13b78 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Oct 2015 14:26:23 +0500 Subject: [PATCH] Cycles: Make sure ray direction is always normalized Ray direction is assumed to be normalized in such areas as scaling intersection distance on instance push/pop when doing ray-scene intersection, but it was possible that some closures wouldn't give normalized direction which could cause wrong intersection checks. Now normalization will happen on surface bounce, which could be a bit of a waste if closure actually gives normalized direction, but currently only transparent BSDF seems to give guaranteed normalized direction. --- intern/cycles/kernel/kernel_path_surface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h index fe85a6b6e4b..4485be8a5b3 100644 --- a/intern/cycles/kernel/kernel_path_surface.h +++ b/intern/cycles/kernel/kernel_path_surface.h @@ -150,7 +150,7 @@ ccl_device bool kernel_branched_path_surface_bounce(KernelGlobals *kg, RNG *rng, /* setup ray */ ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng)); - ray->D = bsdf_omega_in; + ray->D = normalize(bsdf_omega_in); ray->t = FLT_MAX; #ifdef __RAY_DIFFERENTIALS__ ray->dP = ccl_fetch(sd, dP); @@ -257,7 +257,7 @@ ccl_device_inline bool kernel_path_surface_bounce(KernelGlobals *kg, ccl_addr_sp /* setup ray */ ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng)); - ray->D = bsdf_omega_in; + ray->D = normalize(bsdf_omega_in); if(state->bounce == 0) ray->t -= ccl_fetch(sd, ray_length); /* clipping works through transparent */