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
This commit is contained in:
@@ -47,18 +47,19 @@ CCL_NAMESPACE_BEGIN
|
||||
|
||||
using namespace OSL;
|
||||
|
||||
class BSSRDFClosure : public CBSSRDFClosure {
|
||||
/* Cubic */
|
||||
|
||||
class CubicBSSRDFClosure : public CBSSRDFClosure {
|
||||
public:
|
||||
size_t memsize() const { return sizeof(*this); }
|
||||
const char *name() const { return "bssrdf_cubic"; }
|
||||
|
||||
void setup()
|
||||
{
|
||||
sc.type = CLOSURE_BSSRDF_COMPATIBLE_ID;
|
||||
sc.prim = NULL;
|
||||
sc.data0 = fabsf(average(radius));
|
||||
sc.data1 = 1.3f;
|
||||
|
||||
m_shaderdata_flag = bssrdf_setup(&sc);
|
||||
sc.data1 = 0.0f; // XXX texture blur
|
||||
}
|
||||
|
||||
bool mergeable(const ClosurePrimitive *other) const
|
||||
@@ -72,19 +73,59 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
ClosureParam *closure_bssrdf_params()
|
||||
ClosureParam *closure_bssrdf_cubic_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_FLOAT3_PARAM(BSSRDFClosure, sc.N),
|
||||
CLOSURE_FLOAT3_PARAM(BSSRDFClosure, radius),
|
||||
//CLOSURE_FLOAT_PARAM(BSSRDFClosure, sc.data1),
|
||||
CLOSURE_FLOAT3_PARAM(CubicBSSRDFClosure, sc.N),
|
||||
CLOSURE_FLOAT3_PARAM(CubicBSSRDFClosure, radius),
|
||||
//CLOSURE_FLOAT_PARAM(CubicBSSRDFClosure, sc.data1),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_FINISH_PARAM(BSSRDFClosure)
|
||||
CLOSURE_FINISH_PARAM(CubicBSSRDFClosure)
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
CLOSURE_PREPARE(closure_bssrdf_prepare, BSSRDFClosure)
|
||||
CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, CubicBSSRDFClosure)
|
||||
|
||||
/* Gaussian */
|
||||
|
||||
class GaussianBSSRDFClosure : public CBSSRDFClosure {
|
||||
public:
|
||||
size_t memsize() const { return sizeof(*this); }
|
||||
const char *name() const { return "bssrdf_gaussian"; }
|
||||
|
||||
void setup()
|
||||
{
|
||||
sc.type = CLOSURE_BSSRDF_GAUSSIAN_ID;
|
||||
sc.prim = NULL;
|
||||
sc.data0 = fabsf(average(radius));
|
||||
sc.data1 = 0.0f; // XXX texture blurring!
|
||||
}
|
||||
|
||||
bool mergeable(const ClosurePrimitive *other) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void print_on(std::ostream &out) const
|
||||
{
|
||||
out << name() << " ((" << sc.N[0] << ", " << sc.N[1] << ", " << sc.N[2] << "))";
|
||||
}
|
||||
};
|
||||
|
||||
ClosureParam *closure_bssrdf_gaussian_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, sc.N),
|
||||
CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, radius),
|
||||
//CLOSURE_FLOAT_PARAM(GaussianBSSRDFClosure, sc.data1),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_FINISH_PARAM(GaussianBSSRDFClosure)
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
CLOSURE_PREPARE(closure_bssrdf_gaussian_prepare, GaussianBSSRDFClosure)
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
Reference in New Issue
Block a user