From 0df9b2c71517a98760a5e577f434d9d86e4e1910 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 21 Jan 2018 14:04:22 +0100 Subject: Cycles: random walk subsurface scattering. It is basically brute force volume scattering within the mesh, but part of the SSS code for faster performance. The main difference with actual volume scattering is that we assume the boundaries are diffuse and that all lighting is coming through this boundary from outside the volume. This gives much more accurate results for thin features and low density. Some challenges remain however: * Significantly more noisy than BSSRDF. Adding Dwivedi sampling may help here, but it's unclear still how much it helps in real world cases. * Due to this being a volumetric method, geometry like eyes or mouth can darken the skin on the outside. We may be able to reduce this effect, or users can compensate for it by reducing the scattering radius in such areas. * Sharp corners are quite bright. This matches actual volume rendering and results in some other renderers, but maybe not so much real world objects. Differential Revision: https://developer.blender.org/D3054 --- intern/cycles/render/integrator.cpp | 5 ++++- intern/cycles/render/nodes.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'intern/cycles/render') diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 0dc1a9aa053..c337c19ced1 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -187,7 +187,10 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene max_samples = max(max_samples, volume_samples); } - max_samples *= (max_bounce + transparent_max_bounce + 3 + BSSRDF_MAX_HITS); + uint total_bounces = max_bounce + transparent_max_bounce + 3 + + max(BSSRDF_MAX_HITS, BSSRDF_MAX_BOUNCES); + + max_samples *= total_bounces; int dimensions = PRNG_BASE_NUM + max_samples*PRNG_BOUNCE_NUM; dimensions = min(dimensions, SOBOL_MAX_DIMENSIONS); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index acfe07bf112..7e8298e09c1 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2525,6 +2525,7 @@ NODE_DEFINE(SubsurfaceScatteringNode) falloff_enum.insert("cubic", CLOSURE_BSSRDF_CUBIC_ID); falloff_enum.insert("gaussian", CLOSURE_BSSRDF_GAUSSIAN_ID); falloff_enum.insert("burley", CLOSURE_BSSRDF_BURLEY_ID); + falloff_enum.insert("random_walk", CLOSURE_BSSRDF_RANDOM_WALK_ID); SOCKET_ENUM(falloff, "Falloff", falloff_enum, CLOSURE_BSSRDF_BURLEY_ID); SOCKET_IN_FLOAT(scale, "Scale", 0.01f); SOCKET_IN_VECTOR(radius, "Radius", make_float3(0.1f, 0.1f, 0.1f)); -- cgit v1.2.3 From a6968e87f1338081f30725f8f2ca3460e280fea2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Feb 2018 16:19:04 +0100 Subject: Cycles: add random walk subsurface scattering to Principled BSDF. Differential Revision: https://developer.blender.org/D3054 --- intern/cycles/render/nodes.cpp | 9 ++++++++- intern/cycles/render/nodes.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'intern/cycles/render') diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7e8298e09c1..cb884ba9231 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2312,6 +2312,12 @@ NODE_DEFINE(PrincipledBsdfNode) distribution_enum.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID); distribution_enum.insert("Multiscatter GGX", CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); SOCKET_ENUM(distribution, "Distribution", distribution_enum, CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); + + static NodeEnum subsurface_method_enum; + subsurface_method_enum.insert("burley", CLOSURE_BSSRDF_PRINCIPLED_ID); + subsurface_method_enum.insert("random_walk", CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID); + SOCKET_ENUM(subsurface_method, "Subsurface Method", subsurface_method_enum, CLOSURE_BSSRDF_PRINCIPLED_ID); + SOCKET_IN_COLOR(base_color, "Base Color", make_float3(0.8f, 0.8f, 0.8f)); SOCKET_IN_COLOR(subsurface_color, "Subsurface Color", make_float3(0.8f, 0.8f, 0.8f)); SOCKET_IN_FLOAT(metallic, "Metallic", 0.0f); @@ -2410,7 +2416,7 @@ void PrincipledBsdfNode::compile(SVMCompiler& compiler, ShaderInput *p_metallic, compiler.encode_uchar4(sheen_offset, sheen_tint_offset, clearcoat_offset, clearcoat_roughness_offset)); compiler.add_node(compiler.encode_uchar4(ior_offset, transmission_offset, anisotropic_rotation_offset, transmission_roughness_offset), - distribution, SVM_STACK_INVALID, SVM_STACK_INVALID); + distribution, subsurface_method, SVM_STACK_INVALID); float3 bc_default = get_float3(base_color_in->socket_type); @@ -2442,6 +2448,7 @@ void PrincipledBsdfNode::compile(SVMCompiler& compiler) void PrincipledBsdfNode::compile(OSLCompiler& compiler) { compiler.parameter(this, "distribution"); + compiler.parameter(this, "subsurface_method"); compiler.add(this, "node_principled_bsdf"); } diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index a00b48ca5bc..f664ebf545d 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -390,6 +390,7 @@ public: float3 normal, clearcoat_normal, tangent; float surface_mix_weight; ClosureType distribution, distribution_orig; + ClosureType subsurface_method; bool has_integrator_dependency(); void attributes(Shader *shader, AttributeRequestSet *attributes); -- cgit v1.2.3