From ce4915cddb08860f06ccc6a8ce7a7118441674ec Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 Jan 2018 14:09:55 +0100 Subject: Code refactor: store RGB BSSRDF in a single closure. Previously we stored each color channel in a single closure, which was convenient for sampling a closure and channel together. But this doesn't work so well for algorithms where we want to render multiple color channels together. --- intern/cycles/kernel/svm/svm_closure.h | 66 +++++----------------------------- 1 file changed, 8 insertions(+), 58 deletions(-) (limited to 'intern/cycles/kernel/svm/svm_closure.h') diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index 47ebe4288e3..b2fc01f617e 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -191,40 +191,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * float texture_blur = 0.0f; /* create one closure per color channel */ - Bssrdf *bssrdf = bssrdf_alloc(sd, make_float3(subsurf_weight.x, 0.0f, 0.0f)); + Bssrdf *bssrdf = bssrdf_alloc(sd, subsurf_weight); if(bssrdf) { - bssrdf->sample_weight = subsurf_sample_weight; - bssrdf->radius = radius.x; + bssrdf->sample_weight = subsurf_sample_weight * 3.0f; + bssrdf->radius = radius; + bssrdf->albedo = subsurface_color; bssrdf->texture_blur = texture_blur; - bssrdf->albedo = subsurface_color.x; - bssrdf->sharpness = sharpness; - bssrdf->N = N; - bssrdf->roughness = roughness; - - /* setup bsdf */ - sd->flag |= bssrdf_setup(bssrdf, (ClosureType)CLOSURE_BSSRDF_PRINCIPLED_ID); - } - - bssrdf = bssrdf_alloc(sd, make_float3(0.0f, subsurf_weight.y, 0.0f)); - if(bssrdf) { - bssrdf->sample_weight = subsurf_sample_weight; - bssrdf->radius = radius.y; - bssrdf->texture_blur = texture_blur; - bssrdf->albedo = subsurface_color.y; - bssrdf->sharpness = sharpness; - bssrdf->N = N; - bssrdf->roughness = roughness; - - /* setup bsdf */ - sd->flag |= bssrdf_setup(bssrdf, (ClosureType)CLOSURE_BSSRDF_PRINCIPLED_ID); - } - - bssrdf = bssrdf_alloc(sd, make_float3(0.0f, 0.0f, subsurf_weight.z)); - if(bssrdf) { - bssrdf->sample_weight = subsurf_sample_weight; - bssrdf->radius = radius.z; - bssrdf->texture_blur = texture_blur; - bssrdf->albedo = subsurface_color.z; bssrdf->sharpness = sharpness; bssrdf->N = N; bssrdf->roughness = roughness; @@ -803,34 +775,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * float texture_blur = param2; /* create one closure per color channel */ - Bssrdf *bssrdf = bssrdf_alloc(sd, make_float3(weight.x, 0.0f, 0.0f)); - if(bssrdf) { - bssrdf->sample_weight = sample_weight; - bssrdf->radius = radius.x; - bssrdf->texture_blur = texture_blur; - bssrdf->albedo = albedo.x; - bssrdf->sharpness = sharpness; - bssrdf->N = N; - sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type); - } - - bssrdf = bssrdf_alloc(sd, make_float3(0.0f, weight.y, 0.0f)); - if(bssrdf) { - bssrdf->sample_weight = sample_weight; - bssrdf->radius = radius.y; - bssrdf->texture_blur = texture_blur; - bssrdf->albedo = albedo.y; - bssrdf->sharpness = sharpness; - bssrdf->N = N; - sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type); - } - - bssrdf = bssrdf_alloc(sd, make_float3(0.0f, 0.0f, weight.z)); + Bssrdf *bssrdf = bssrdf_alloc(sd, weight); if(bssrdf) { - bssrdf->sample_weight = sample_weight; - bssrdf->radius = radius.z; + bssrdf->sample_weight = sample_weight * 3.0f; + bssrdf->radius = radius; + bssrdf->albedo = albedo; bssrdf->texture_blur = texture_blur; - bssrdf->albedo = albedo.z; bssrdf->sharpness = sharpness; bssrdf->N = N; sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type); -- cgit v1.2.3