diff options
Diffstat (limited to 'intern/cycles/kernel/kernel_bake.h')
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index b3c2450d10e..79e6d1b4862 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -330,15 +330,30 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, switch(type) { /* data passes */ case SHADER_EVAL_NORMAL: + case SHADER_EVAL_ROUGHNESS: + case SHADER_EVAL_EMISSION: { - float3 N = sd.N; - if((sd.flag & SD_HAS_BUMP)) { - shader_eval_surface(kg, &sd, &state, 0); - N = shader_bsdf_average_normal(kg, &sd); + if(type != SHADER_EVAL_NORMAL || (sd.flag & SD_HAS_BUMP)) { + int path_flag = (type == SHADER_EVAL_EMISSION) ? PATH_RAY_EMISSION : 0; + shader_eval_surface(kg, &sd, &state, path_flag); } - /* encoding: normal = (2 * color) - 1 */ - out = N * 0.5f + make_float3(0.5f, 0.5f, 0.5f); + if(type == SHADER_EVAL_NORMAL) { + float3 N = sd.N; + if(sd.flag & SD_HAS_BUMP) { + N = shader_bsdf_average_normal(kg, &sd); + } + + /* encoding: normal = (2 * color) - 1 */ + out = N * 0.5f + make_float3(0.5f, 0.5f, 0.5f); + } + else if(type == SHADER_EVAL_ROUGHNESS) { + float roughness = shader_bsdf_average_roughness(&sd); + out = make_float3(roughness, roughness, roughness); + } + else { + out = shader_emissive_eval(kg, &sd); + } break; } case SHADER_EVAL_UV: @@ -346,13 +361,6 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, out = primitive_uv(kg, &sd); break; } - case SHADER_EVAL_EMISSION: - { - shader_eval_surface(kg, &sd, &state, PATH_RAY_EMISSION); - out = shader_emissive_eval(kg, &sd); - break; - } - #ifdef __PASSES__ /* light passes */ case SHADER_EVAL_AO: |