diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-04-28 19:29:13 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-04-28 20:55:12 +0300 |
commit | c722993ef19d6e6a564311f4bdc3cfb214b1474a (patch) | |
tree | 2d92b34620ed5a03c22a4db680f2839d391312b1 /intern/cycles/kernel/integrator/init_from_bake.h | |
parent | 5b1ec08f040ab238b2f4d80fa3bc7b169eeb3820 (diff) |
Fix T94467: Cycles baking of normal pass slower than before cycles-x
Diffstat (limited to 'intern/cycles/kernel/integrator/init_from_bake.h')
-rw-r--r-- | intern/cycles/kernel/integrator/init_from_bake.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/intern/cycles/kernel/integrator/init_from_bake.h b/intern/cycles/kernel/integrator/init_from_bake.h index d6047bd2288..3772db845a8 100644 --- a/intern/cycles/kernel/integrator/init_from_bake.h +++ b/intern/cycles/kernel/integrator/init_from_bake.h @@ -192,6 +192,19 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg, Ng = normalize(transform_direction_transposed(&itfm, Ng)); } + const int shader_index = shader & SHADER_MASK; + const int shader_flags = kernel_tex_fetch(__shaders, shader_index).flags; + + /* Fast path for position and normal passes not affected by shaders. */ + if (kernel_data.film.pass_position != PASS_UNUSED) { + kernel_write_pass_float3(buffer + kernel_data.film.pass_position, P); + return true; + } + else if (kernel_data.film.pass_normal != PASS_UNUSED && !(shader_flags & SD_HAS_BUMP)) { + kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, N); + return true; + } + /* Setup ray. */ Ray ray ccl_optional_struct_init; ray.P = P + N; @@ -228,8 +241,6 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg, integrator_state_write_isect(kg, state, &isect); /* Setup next kernel to execute. */ - const int shader_index = shader & SHADER_MASK; - const int shader_flags = kernel_tex_fetch(__shaders, shader_index).flags; const bool use_caustics = kernel_data.integrator.use_caustics && (object_flag & SD_OBJECT_CAUSTICS); const bool use_raytrace_kernel = (shader_flags & SD_HAS_RAYTRACE) || use_caustics; |