diff options
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 67 |
2 files changed, 60 insertions, 10 deletions
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 6e2365d7831..3c07ddd3bcb 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -1338,7 +1338,7 @@ public: } #define KERNEL_TEX(type, ttype, name) \ - set_kernel_arg_mem(kernel, &start_arg_index, #name); + set_kernel_arg_mem(kernel, &start_arg_index, #name); #include "kernel_textures.h" #undef KERNEL_TEX @@ -1347,6 +1347,7 @@ public: d_shader_eval_type); if(task.shader_eval_type >= SHADER_EVAL_BAKE) { start_arg_index += kernel_set_args(kernel, + start_arg_index, d_shader_filter); } start_arg_index += kernel_set_args(kernel, diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index 31e58de0b48..4e4b63a2e1d 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -214,9 +214,34 @@ ccl_device_inline float bake_clamp_mirror_repeat(float u) return (((int)fu) & 1)? 1.0f - u: u; } -ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg, ShaderData *sd, PathState *state, - float3 (*shader_bsdf)(KernelGlobals *kg, ShaderData *sd), - float3 direct, float3 indirect, const int pass_filter) +ccl_device_inline float3 kernel_bake_shader_bsdf(KernelGlobals *kg, + ShaderData *sd, + const ShaderEvalType type) +{ + switch(type) { + case SHADER_EVAL_DIFFUSE: + return shader_bsdf_diffuse(kg, sd); + case SHADER_EVAL_GLOSSY: + return shader_bsdf_glossy(kg, sd); + case SHADER_EVAL_TRANSMISSION: + return shader_bsdf_transmission(kg, sd); +#ifdef __SUBSURFACE__ + case SHADER_EVAL_SUBSURFACE: + return shader_bsdf_subsurface(kg, sd); +#endif + default: + kernel_assert(!"Unknown bake type passed to BSDF evaluate"); + return make_float3(0.0f, 0.0f, 0.0f); + } +} + +ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg, + ShaderData *sd, + PathState *state, + float3 direct, + float3 indirect, + const ShaderEvalType type, + const int pass_filter) { float3 color; const bool is_color = (pass_filter & BAKE_FILTER_COLOR) != 0; @@ -232,12 +257,12 @@ ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg, Shader else { /* surface color of the pass only */ shader_eval_surface(kg, sd, state, 0.0f, 0, SHADER_CONTEXT_MAIN); - return shader_bsdf(kg, sd); + return kernel_bake_shader_bsdf(kg, sd, type); } } else { shader_eval_surface(kg, sd, state, 0.0f, 0, SHADER_CONTEXT_MAIN); - color = shader_bsdf(kg, sd); + color = kernel_bake_shader_bsdf(kg, sd, type); } if(is_direct) { @@ -411,23 +436,47 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, } case SHADER_EVAL_DIFFUSE: { - out = kernel_bake_evaluate_direct_indirect(kg, &sd, &state, &shader_bsdf_diffuse, L.direct_diffuse, L.indirect_diffuse, pass_filter); + out = kernel_bake_evaluate_direct_indirect(kg, + &sd, + &state, + L.direct_diffuse, + L.indirect_diffuse, + type, + pass_filter); break; } case SHADER_EVAL_GLOSSY: { - out = kernel_bake_evaluate_direct_indirect(kg, &sd, &state, &shader_bsdf_glossy, L.direct_glossy, L.indirect_glossy, pass_filter); + out = kernel_bake_evaluate_direct_indirect(kg, + &sd, + &state, + L.direct_glossy, + L.indirect_glossy, + type, + pass_filter); break; } case SHADER_EVAL_TRANSMISSION: { - out = kernel_bake_evaluate_direct_indirect(kg, &sd, &state, &shader_bsdf_transmission, L.direct_transmission, L.indirect_transmission, pass_filter); + out = kernel_bake_evaluate_direct_indirect(kg, + &sd, + &state, + L.direct_transmission, + L.indirect_transmission, + type, + pass_filter); break; } case SHADER_EVAL_SUBSURFACE: { #ifdef __SUBSURFACE__ - out = kernel_bake_evaluate_direct_indirect(kg, &sd, &state, &shader_bsdf_subsurface, L.direct_subsurface, L.indirect_subsurface, pass_filter); + out = kernel_bake_evaluate_direct_indirect(kg, + &sd, + &state, + L.direct_subsurface, + L.indirect_subsurface, + type, + pass_filter); #endif break; } |