diff options
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r-- | intern/cycles/kernel/svm/svm.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_closure.h | 65 |
2 files changed, 32 insertions, 41 deletions
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index d748e76fa80..f0b3adcdad5 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -207,7 +207,9 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a break; } case NODE_CLOSURE_BSDF: - svm_node_closure_bsdf(kg, sd, stack, node, path_flag, &offset); + if(type == SHADER_TYPE_SURFACE) { + svm_node_closure_bsdf(kg, sd, stack, node, path_flag, &offset); + } break; case NODE_CLOSURE_EMISSION: svm_node_closure_emission(sd, stack, node); @@ -325,7 +327,9 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a break; # if NODES_FEATURE(NODE_FEATURE_VOLUME) case NODE_CLOSURE_VOLUME: - svm_node_closure_volume(kg, sd, stack, node, path_flag); + if(type == SHADER_TYPE_VOLUME) { + svm_node_closure_volume(kg, sd, stack, node, 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 f1ed9af1064..4afb91e732b 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -446,12 +446,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * } case CLOSURE_BSDF_TRANSPARENT_ID: { float3 weight = sd->svm_closure_weight * mix_weight; - ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight); - - if(bsdf) { - bsdf->N = N; - sd->flag |= bsdf_transparent_setup(bsdf); - } + bsdf_transparent_setup(sd, weight); break; } case CLOSURE_BSDF_REFLECTION_ID: @@ -708,18 +703,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * float3 weight = sd->svm_closure_weight * mix_weight; if(sd->flag & SD_BACKFACING && sd->type & PRIMITIVE_ALL_CURVE) { - ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight); - - if(bsdf) { - bsdf->N = N; - /* todo: giving a fixed weight here will cause issues when - * mixing multiple BSDFS. energy will not be conserved and - * the throughput can blow up after multiple bounces. we - * better figure out a way to skip backfaces from rays - * spawned by transmission from the front */ - bsdf->weight = make_float3(1.0f, 1.0f, 1.0f); - sd->flag |= bsdf_transparent_setup(bsdf); - } + /* todo: giving a fixed weight here will cause issues when + * mixing multiple BSDFS. energy will not be conserved and + * the throughput can blow up after multiple bounces. we + * better figure out a way to skip backfaces from rays + * spawned by transmission from the front */ + bsdf_transparent_setup(sd, make_float3(1.0f, 1.0f, 1.0f)); } else { HairBsdf *bsdf = (HairBsdf*)bsdf_alloc(sd, sizeof(HairBsdf), weight); @@ -831,32 +820,30 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float return; float param1 = (stack_valid(param1_offset))? stack_load_float(stack, param1_offset): __uint_as_float(node.z); - float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w); - float density = fmaxf(param1, 0.0f); - switch(type) { - case CLOSURE_VOLUME_ABSORPTION_ID: { - float3 weight = (make_float3(1.0f, 1.0f, 1.0f) - sd->svm_closure_weight) * mix_weight * density; - ShaderClosure *sc = closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_NONE_ID, weight); + /* Compute scattering coefficient. */ + float density = mix_weight * fmaxf(param1, 0.0f); + float3 weight = sd->svm_closure_weight; - if(sc) { - sd->flag |= volume_absorption_setup(sc); - } - break; - } - case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID: { - float3 weight = sd->svm_closure_weight * mix_weight * density; - HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), weight); + if(type == CLOSURE_VOLUME_ABSORPTION_ID) { + weight = make_float3(1.0f, 1.0f, 1.0f) - weight; + } - if(volume) { - volume->g = param2; /* g */ - sd->flag |= volume_henyey_greenstein_setup(volume); - } - break; + weight *= density; + + /* Add closure for volume scattering. */ + if(type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID) { + float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w); + HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), weight); + + if(volume) { + volume->g = param2; /* g */ + sd->flag |= volume_henyey_greenstein_setup(volume); } - default: - break; } + + /* Sum total extinction weight. */ + volume_extinction_setup(sd, weight); #endif } |