diff options
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/svm/svm.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_closure.h | 21 |
2 files changed, 20 insertions, 9 deletions
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 9ff02c1586b..d3dac5706d0 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -211,9 +211,7 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a break; } case NODE_CLOSURE_BSDF: - if(type == SHADER_TYPE_SURFACE) { - svm_node_closure_bsdf(kg, sd, stack, node, path_flag, &offset); - } + svm_node_closure_bsdf(kg, sd, stack, node, type, path_flag, &offset); break; case NODE_CLOSURE_EMISSION: svm_node_closure_emission(sd, stack, node); @@ -331,9 +329,7 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a break; # if NODES_FEATURE(NODE_FEATURE_VOLUME) case NODE_CLOSURE_VOLUME: - if(type == SHADER_TYPE_VOLUME) { - svm_node_closure_volume(kg, sd, stack, node, path_flag); - } + svm_node_closure_volume(kg, sd, stack, node, type, path_flag); break; # endif /* NODES_FEATURE(NODE_FEATURE_VOLUME) */ # ifdef __EXTRA_NODES__ diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index f04c46ef7f9..47ebe4288e3 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -56,7 +56,7 @@ ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int t } } -ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag, int *offset) +ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag, int *offset) { uint type, param1_offset, param2_offset; @@ -67,8 +67,18 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * /* note we read this extra node before weight check, so offset is added */ uint4 data_node = read_node(kg, offset); - if(mix_weight == 0.0f) + /* Only compute BSDF for surfaces, transparent variable is shared with volume extinction. */ + if(mix_weight == 0.0f || shader_type != SHADER_TYPE_SURFACE) { + if(type == CLOSURE_BSDF_PRINCIPLED_ID) { + /* Read all principled BSDF extra data to get the right offset. */ + read_node(kg, offset); + read_node(kg, offset); + read_node(kg, offset); + read_node(kg, offset); + } + return; + } float3 N = stack_valid(data_node.x)? stack_load_float3(stack, data_node.x): sd->N; @@ -835,9 +845,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * } } -ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag) +ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag) { #ifdef __VOLUME__ + /* Only sum extinction for volumes, variable is shared with surface transparency. */ + if(shader_type != SHADER_TYPE_VOLUME) { + return; + } + uint type, param1_offset, param2_offset; uint mix_weight_offset; |