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 */