From 60ca0558c031efcb81e9dcc89f95fc370cf80f96 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 24 Aug 2013 15:36:14 +0000 Subject: [PATCH] Fix issue in last subsurface commit with branched path tracing, was rendering too bright. --- intern/cycles/kernel/kernel_subsurface.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h index 5eb641f5af4..2c394327f21 100644 --- a/intern/cycles/kernel/kernel_subsurface.h +++ b/intern/cycles/kernel/kernel_subsurface.h @@ -221,18 +221,26 @@ __device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, Sh disk_N = sd->Ng; make_orthonormals(disk_N, &disk_T, &disk_B); - if(sd->randb_closure < 0.5f) { + /* reusing variable for picking the closure gives a bit nicer stratification + * for path tracer, for branched we do all closures so it doesn't help */ + float axisu = (all)? disk_u: sd->randb_closure; + + if(axisu < 0.5f) { pick_pdf_N = 0.5f; pick_pdf_T = 0.25f; pick_pdf_B = 0.25f; + if(all) + disk_u *= 2.0f; } - else if(sd->randb_closure < 0.75f) { + else if(axisu < 0.75f) { float3 tmp = disk_N; disk_N = disk_T; disk_T = tmp; pick_pdf_N = 0.25f; pick_pdf_T = 0.5f; pick_pdf_B = 0.25f; + if(all) + disk_u = (disk_u - 0.5f)*4.0f; } else { float3 tmp = disk_N; @@ -241,6 +249,8 @@ __device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, Sh pick_pdf_N = 0.25f; pick_pdf_T = 0.25f; pick_pdf_B = 0.5f; + if(all) + disk_u = (disk_u - 0.75f)*4.0f; } /* sample point on disk */