Cycles: Fix wrong termination criteria in intersect_all functions
It was possible to miss bounces termination criteria in this functions, mainly when max_hits was set to 0. Made the check more robust in traversal functions (which should not affect performance, it's an operation of same complexity AFAIK). Also avoid doing ray-scene intersection from shadow_blocked when limit of transparent bounces was already reached.
This commit is contained in:
parent
103a515043
commit
3637cbbcf8
|
@ -283,7 +283,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
|||
return true;
|
||||
}
|
||||
/* if maximum number of hits reached, block all light */
|
||||
else if(*num_hits == max_hits) {
|
||||
else if(*num_hits >= max_hits) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
|||
#if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
#endif
|
||||
if(num_hits == max_hits) {
|
||||
if(num_hits >= max_hits) {
|
||||
#if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
|
@ -252,7 +252,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
|||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
# endif
|
||||
if(num_hits == max_hits) {
|
||||
if(num_hits >= max_hits) {
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
|
|
|
@ -366,7 +366,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
|||
return true;
|
||||
}
|
||||
/* if maximum number of hits reached, block all light */
|
||||
else if(*num_hits == max_hits) {
|
||||
else if(*num_hits >= max_hits) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
|||
#if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
#endif
|
||||
if(num_hits == max_hits) {
|
||||
if(num_hits >= max_hits) {
|
||||
#if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
|
@ -312,7 +312,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
|||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
num_hits_in_instance++;
|
||||
# endif
|
||||
if(num_hits == max_hits) {
|
||||
if(num_hits >= max_hits) {
|
||||
# if BVH_FEATURE(BVH_INSTANCING)
|
||||
# if BVH_FEATURE(BVH_MOTION)
|
||||
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
|
||||
|
|
|
@ -75,7 +75,12 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *shadow_sd,
|
|||
}
|
||||
|
||||
uint num_hits;
|
||||
blocked = scene_intersect_shadow_all(kg, ray, hits, max_hits, &num_hits);
|
||||
if(max_hits == 0) {
|
||||
blocked = true;
|
||||
num_hits = 0;
|
||||
} else {
|
||||
blocked = scene_intersect_shadow_all(kg, ray, hits, max_hits, &num_hits);
|
||||
}
|
||||
|
||||
/* if no opaque surface found but we did find transparent hits, shade them */
|
||||
if(!blocked && num_hits > 0) {
|
||||
|
|
Loading…
Reference in New Issue