diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-21 13:39:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-08 16:00:48 +0300 |
commit | 58a10122d0c7f7fb85ec2ee805886c986c09d746 (patch) | |
tree | 85a4d6e5086619271d7b274e99cdc5e2bb7cedd7 /intern | |
parent | 98a1855803d6801dd3aa485850c6059af3dc5daf (diff) |
Cycles: Make GPU version of shadow_blocked() closer to CPU
Now we break the traversal cycle and then perform volume attenuation
and check with zero throughput. Not sure it makes any measurable sense
at this moment, but in the future it might help de-duplicating some
extra logic here.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/kernel_shadow.h | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h index cc037e13105..f24bca47cd6 100644 --- a/intern/cycles/kernel/kernel_shadow.h +++ b/intern/cycles/kernel/kernel_shadow.h @@ -170,12 +170,11 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *shadow_sd, #ifdef __VOLUME__ /* Attenuation for last line segment towards light. */ - if(ps.volume_stack[0].shader != SHADER_NONE) + if(ps.volume_stack[0].shader != SHADER_NONE) { kernel_volume_shadow(kg, shadow_sd, &ps, ray, &throughput); + } #endif - *shadow = throughput; - return is_zero(throughput); } } @@ -230,9 +229,13 @@ ccl_device_noinline bool shadow_blocked(KernelGlobals *kg, Intersection isect_object; Intersection *isect = &isect_object; #endif - - bool blocked = scene_intersect(kg, *ray, PATH_RAY_SHADOW_OPAQUE, isect, NULL, 0.0f, 0.0f); - + /* Early check for opaque shadows. */ + bool blocked = scene_intersect(kg, + *ray, + PATH_RAY_SHADOW_OPAQUE, + isect, + NULL, + 0.0f, 0.0f); #ifdef __TRANSPARENT_SHADOWS__ if(blocked && kernel_data.integrator.transparent_shadows) { if(shader_transparent_shadow(kg, isect)) { @@ -243,20 +246,16 @@ ccl_device_noinline bool shadow_blocked(KernelGlobals *kg, PathState ps = *state; # endif for(;;) { - if(bounce >= kernel_data.integrator.transparent_max_bounce) + if(bounce >= kernel_data.integrator.transparent_max_bounce) { return true; - - if(!scene_intersect(kg, *ray, PATH_RAY_SHADOW_TRANSPARENT, isect, NULL, 0.0f, 0.0f)) + if(!scene_intersect(kg, + *ray, + PATH_RAY_SHADOW_TRANSPARENT, + isect, + NULL, + 0.0f, 0.0f)) { -# ifdef __VOLUME__ - /* Attenuation for last line segment towards light. */ - if(ps.volume_stack[0].shader != SHADER_NONE) - kernel_volume_shadow(kg, shadow_sd, &ps, ray, &throughput); -# endif - - *shadow *= throughput; - - return false; + break; } if(!shader_transparent_shadow(kg, isect)) { return true; @@ -278,11 +277,19 @@ ccl_device_noinline bool shadow_blocked(KernelGlobals *kg, } bounce++; } +# ifdef __VOLUME__ + /* Attenuation for last line segment towards light. */ + if(ps.volume_stack[0].shader != SHADER_NONE) { + kernel_volume_shadow(kg, shadow_sd, &ps, ray, &throughput); + } +# endif + *shadow *= throughput; + return is_zero(throughput); } } # ifdef __VOLUME__ else if(!blocked && state->volume_stack[0].shader != SHADER_NONE) { - /* apply attenuation from current volume shader */ + /* Apply attenuation from current volume shader. */ kernel_volume_shadow(kg, shadow_sd, state, ray, shadow); } # endif |