diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-18 18:15:57 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-18 18:15:57 +0400 |
commit | d43682d51bbe70448b328980d29c3a08cf4d4a26 (patch) | |
tree | f4e265a9280e67756d8cb284a392dc1ed084b96f /intern/cycles/render/nodes.cpp | |
parent | a2541508ac9918ce614b87a88f25993788b3ce3b (diff) |
Cycles: Subsurface Scattering
New features:
* Bump mapping now works with SSS
* Texture Blur factor for SSS, see the documentation for details:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Subsurface_Scattering
Work in progress for feedback:
Initial implementation of the "BSSRDF Importance Sampling" paper, which uses
a different importance sampling method. It gives better quality results in
many ways, with the availability of both Cubic and Gaussian falloff functions,
but also tends to be more noisy when using the progressive integrator and does
not give great results with some geometry. It works quite well for the
non-progressive integrator and is often less noisy there.
This code may still change a lot, so unless you're testing it may be best to
stick to the Compatible falloff function.
Skin test render and file that takes advantage of the gaussian falloff:
http://www.pasteall.org/pic/show.php?id=57661
http://www.pasteall.org/pic/show.php?id=57662
http://www.pasteall.org/blend/23501
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index db402c5fc9f..70fa30fe03b 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1276,16 +1276,18 @@ void ProxyNode::compile(OSLCompiler& compiler) BsdfNode::BsdfNode(bool scattering_) : ShaderNode("bsdf"), scattering(scattering_) { - closure = ccl::CLOSURE_BSSRDF_ID; - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL); add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); - if(scattering) + if(scattering) { + closure = CLOSURE_BSSRDF_CUBIC_ID; add_output("BSSRDF", SHADER_SOCKET_CLOSURE); - else + } + else { + closure = CLOSURE_BSDF_DIFFUSE_ID; add_output("BSDF", SHADER_SOCKET_CLOSURE); + } } void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3) @@ -1600,27 +1602,47 @@ void TransparentBsdfNode::compile(OSLCompiler& compiler) /* Subsurface Scattering Closure */ +static ShaderEnum subsurface_falloff_init() +{ + ShaderEnum enm; + + enm.insert("Cubic", CLOSURE_BSSRDF_CUBIC_ID); + enm.insert("Gaussian", CLOSURE_BSSRDF_GAUSSIAN_ID); + + return enm; +} + +ShaderEnum SubsurfaceScatteringNode::falloff_enum = subsurface_falloff_init(); + SubsurfaceScatteringNode::SubsurfaceScatteringNode() : BsdfNode(true) { name = "subsurface_scattering"; - closure = CLOSURE_BSSRDF_ID; + closure = CLOSURE_BSSRDF_CUBIC_ID; add_input("Scale", SHADER_SOCKET_FLOAT, 0.01f); add_input("Radius", SHADER_SOCKET_VECTOR, make_float3(0.1f, 0.1f, 0.1f)); - add_input("IOR", SHADER_SOCKET_FLOAT, 1.3f); + add_input("Texture Blur", SHADER_SOCKET_FLOAT, 1.0f); } void SubsurfaceScatteringNode::compile(SVMCompiler& compiler) { - BsdfNode::compile(compiler, input("Scale"), input("IOR"), input("Radius")); + BsdfNode::compile(compiler, input("Scale"), input("Texture Blur"), input("Radius")); } void SubsurfaceScatteringNode::compile(OSLCompiler& compiler) { + compiler.parameter("Falloff", falloff_enum[closure]); compiler.add(this, "node_subsurface_scattering"); } +bool SubsurfaceScatteringNode::has_bssrdf_bump() +{ + /* detect if anything is plugged into the normal input besides the default */ + ShaderInput *normal_in = input("Normal"); + return (normal_in->link && normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY); +} + /* Emissive Closure */ EmissionNode::EmissionNode() @@ -1835,6 +1857,8 @@ void IsotropicVolumeNode::compile(OSLCompiler& compiler) GeometryNode::GeometryNode() : ShaderNode("geometry") { + special_type = SHADER_SPECIAL_TYPE_GEOMETRY; + add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); add_output("Position", SHADER_SOCKET_POINT); add_output("Normal", SHADER_SOCKET_NORMAL); |