forked from bartvdbraak/blender
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.
This commit is contained in:
parent
29247a7a05
commit
b54447c0eb
@ -150,7 +150,7 @@ ccl_device bool kernel_branched_path_surface_bounce(KernelGlobals *kg, RNG *rng,
|
|||||||
|
|
||||||
/* setup ray */
|
/* setup ray */
|
||||||
ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng));
|
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;
|
ray->t = FLT_MAX;
|
||||||
#ifdef __RAY_DIFFERENTIALS__
|
#ifdef __RAY_DIFFERENTIALS__
|
||||||
ray->dP = ccl_fetch(sd, dP);
|
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 */
|
/* setup ray */
|
||||||
ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng));
|
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)
|
if(state->bounce == 0)
|
||||||
ray->t -= ccl_fetch(sd, ray_length); /* clipping works through transparent */
|
ray->t -= ccl_fetch(sd, ray_length); /* clipping works through transparent */
|
||||||
|
Loading…
Reference in New Issue
Block a user