Fix for a case of 'static initialization fiasco' with OSL closure variables. The parameter lists are using OIIO::TypeDesc static standards, which are also static variables. With static OSL libraries these are not initialized when the closure parameter lists are initialized, so OSL rejects the closure types.

Putting static initialization into functions works just as well, but ensures the OIIO::TypeDesc access is delayed until initialization is complete.
This commit is contained in:
Lukas Toenne 2012-10-06 16:28:02 +00:00
parent 2ecb4781a7
commit 78978dcd80
17 changed files with 258 additions and 167 deletions

@ -85,16 +85,25 @@ public:
} }
}; };
ClosureParam closure_background_params[] = {
ClosureParam *closure_background_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericBackgroundClosure) CLOSURE_FINISH_PARAM(GenericBackgroundClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_background_prepare, GenericBackgroundClosure) CLOSURE_PREPARE(closure_background_prepare, GenericBackgroundClosure)
ClosureParam closure_holdout_params[] = { ClosureParam *closure_holdout_params()
{
static ClosureParam params[] = {
CLOSURE_FINISH_PARAM(HoldoutClosure) CLOSURE_FINISH_PARAM(HoldoutClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure) CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)

@ -173,12 +173,16 @@ public:
ClosureParam bsdf_ashikhmin_velvet_params[] = { ClosureParam *bsdf_ashikhmin_velvet_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N), CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N),
CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma), CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(AshikhminVelvetClosure) CLOSURE_FINISH_PARAM(AshikhminVelvetClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_ashikhmin_velvet_prepare, AshikhminVelvetClosure) CLOSURE_PREPARE(bsdf_ashikhmin_velvet_prepare, AshikhminVelvetClosure)

@ -168,17 +168,25 @@ public:
} }
}; };
ClosureParam bsdf_diffuse_params[] = { ClosureParam *bsdf_diffuse_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N), CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(DiffuseClosure) CLOSURE_FINISH_PARAM(DiffuseClosure)
}; };
return params;
}
ClosureParam bsdf_translucent_params[] = { ClosureParam *bsdf_translucent_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N), CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(TranslucentClosure) CLOSURE_FINISH_PARAM(TranslucentClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_diffuse_prepare, DiffuseClosure) CLOSURE_PREPARE(bsdf_diffuse_prepare, DiffuseClosure)
CLOSURE_PREPARE(bsdf_translucent_prepare, TranslucentClosure) CLOSURE_PREPARE(bsdf_translucent_prepare, TranslucentClosure)

@ -503,35 +503,51 @@ public:
ClosureParam bsdf_microfacet_ggx_params[] = { ClosureParam *bsdf_microfacet_ggx_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N), CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag), CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>) CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>)
}; };
return params;
}
ClosureParam bsdf_microfacet_ggx_refraction_params[] = { ClosureParam *bsdf_microfacet_ggx_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N), CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag), CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta), CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>) CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>)
}; };
return params;
}
ClosureParam bsdf_microfacet_beckmann_params[] = { ClosureParam *bsdf_microfacet_beckmann_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N), CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab), CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>) CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>)
}; };
return params;
}
ClosureParam bsdf_microfacet_beckmann_refraction_params[] = { ClosureParam *bsdf_microfacet_beckmann_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N), CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab), CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta), CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>) CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_microfacet_ggx_prepare, MicrofacetGGXClosure<0>) CLOSURE_PREPARE(bsdf_microfacet_ggx_prepare, MicrofacetGGXClosure<0>)
CLOSURE_PREPARE(bsdf_microfacet_ggx_refraction_prepare, MicrofacetGGXClosure<1>) CLOSURE_PREPARE(bsdf_microfacet_ggx_refraction_prepare, MicrofacetGGXClosure<1>)

@ -125,12 +125,16 @@ private:
} }
}; };
ClosureParam bsdf_oren_nayar_params[] = { ClosureParam *bsdf_oren_nayar_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(OrenNayarClosure, m_N), CLOSURE_VECTOR_PARAM(OrenNayarClosure, m_N),
CLOSURE_FLOAT_PARAM(OrenNayarClosure, m_sigma), CLOSURE_FLOAT_PARAM(OrenNayarClosure, m_sigma),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(OrenNayarClosure) CLOSURE_FINISH_PARAM(OrenNayarClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_oren_nayar_prepare, OrenNayarClosure) CLOSURE_PREPARE(bsdf_oren_nayar_prepare, OrenNayarClosure)

@ -258,18 +258,28 @@ public:
ClosureParam bsdf_phong_params[] = { ClosureParam *bsdf_phong_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(PhongClosure, m_N), CLOSURE_VECTOR_PARAM(PhongClosure, m_N),
CLOSURE_FLOAT_PARAM (PhongClosure, m_exponent), CLOSURE_FLOAT_PARAM (PhongClosure, m_exponent),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(PhongClosure) }; CLOSURE_FINISH_PARAM(PhongClosure)
};
return params;
}
ClosureParam bsdf_phong_ramp_params[] = { ClosureParam *bsdf_phong_ramp_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM (PhongRampClosure, m_N), CLOSURE_VECTOR_PARAM (PhongRampClosure, m_N),
CLOSURE_FLOAT_PARAM (PhongRampClosure, m_exponent), CLOSURE_FLOAT_PARAM (PhongRampClosure, m_exponent),
CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, m_colors, PhongRampClosure::MAXCOLORS), CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, m_colors, PhongRampClosure::MAXCOLORS),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM (PhongRampClosure) }; CLOSURE_FINISH_PARAM (PhongRampClosure)
};
return params;
}
CLOSURE_PREPARE(bsdf_phong_prepare, PhongClosure) CLOSURE_PREPARE(bsdf_phong_prepare, PhongClosure)
CLOSURE_PREPARE(bsdf_phong_ramp_prepare, PhongRampClosure) CLOSURE_PREPARE(bsdf_phong_ramp_prepare, PhongRampClosure)

@ -97,11 +97,15 @@ public:
} }
}; };
ClosureParam bsdf_reflection_params[] = { ClosureParam *bsdf_reflection_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N), CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(ReflectionClosure) CLOSURE_FINISH_PARAM(ReflectionClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_reflection_prepare, ReflectionClosure) CLOSURE_PREPARE(bsdf_reflection_prepare, ReflectionClosure)

@ -108,12 +108,16 @@ public:
} }
}; };
ClosureParam bsdf_refraction_params[] = { ClosureParam *bsdf_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(RefractionClosure, m_N), CLOSURE_VECTOR_PARAM(RefractionClosure, m_N),
CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta), CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(RefractionClosure) CLOSURE_FINISH_PARAM(RefractionClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_refraction_prepare, RefractionClosure) CLOSURE_PREPARE(bsdf_refraction_prepare, RefractionClosure)

@ -87,10 +87,14 @@ public:
ClosureParam bsdf_transparent_params[] = { ClosureParam *bsdf_transparent_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(TransparentClosure) CLOSURE_FINISH_PARAM(TransparentClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_transparent_prepare, TransparentClosure) CLOSURE_PREPARE(bsdf_transparent_prepare, TransparentClosure)

@ -211,14 +211,18 @@ public:
ClosureParam bsdf_ward_params[] = { ClosureParam *bsdf_ward_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WardClosure, m_N), CLOSURE_VECTOR_PARAM(WardClosure, m_N),
CLOSURE_VECTOR_PARAM(WardClosure, m_T), CLOSURE_VECTOR_PARAM(WardClosure, m_T),
CLOSURE_FLOAT_PARAM(WardClosure, m_ax), CLOSURE_FLOAT_PARAM(WardClosure, m_ax),
CLOSURE_FLOAT_PARAM(WardClosure, m_ay), CLOSURE_FLOAT_PARAM(WardClosure, m_ay),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WardClosure) CLOSURE_FINISH_PARAM(WardClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_ward_prepare, WardClosure) CLOSURE_PREPARE(bsdf_ward_prepare, WardClosure)

@ -222,19 +222,27 @@ public:
ClosureParam bsdf_westin_backscatter_params[] = { ClosureParam *bsdf_westin_backscatter_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N), CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness), CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinBackscatterClosure) CLOSURE_FINISH_PARAM(WestinBackscatterClosure)
}; };
return params;
}
ClosureParam bsdf_westin_sheen_params[] = { ClosureParam *bsdf_westin_sheen_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N), CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess), CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinSheenClosure) CLOSURE_FINISH_PARAM(WestinSheenClosure)
}; };
return params;
}
CLOSURE_PREPARE(bsdf_westin_backscatter_prepare, WestinBackscatterClosure) CLOSURE_PREPARE(bsdf_westin_backscatter_prepare, WestinBackscatterClosure)
CLOSURE_PREPARE(bsdf_westin_sheen_prepare, WestinSheenClosure) CLOSURE_PREPARE(bsdf_westin_sheen_prepare, WestinSheenClosure)

@ -94,11 +94,15 @@ public:
ClosureParam closure_bssrdf_cubic_params[] = { ClosureParam *closure_bssrdf_cubic_params()
{
static ClosureParam params[] = {
CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius), CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(BSSRDFCubicClosure) CLOSURE_FINISH_PARAM(BSSRDFCubicClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, BSSRDFCubicClosure) CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, BSSRDFCubicClosure)

@ -69,11 +69,15 @@ public:
}; };
ClosureParam closure_debug_params[] = { ClosureParam *closure_debug_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_PARAM(DebugClosure, m_tag), CLOSURE_STRING_PARAM(DebugClosure, m_tag),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(DebugClosure) CLOSURE_FINISH_PARAM(DebugClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_debug_prepare, DebugClosure) CLOSURE_PREPARE(closure_debug_prepare, DebugClosure)

@ -97,10 +97,14 @@ public:
ClosureParam closure_emission_params[] = { ClosureParam *closure_emission_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericEmissiveClosure) CLOSURE_FINISH_PARAM(GenericEmissiveClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure) CLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure)

@ -64,28 +64,28 @@ static void register_closure(OSL::ShadingSystem *ss, const char *name, int id, O
void OSLShader::register_closures(OSL::ShadingSystem *ss) void OSLShader::register_closures(OSL::ShadingSystem *ss)
{ {
register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params, bsdf_diffuse_prepare); register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params(), bsdf_diffuse_prepare);
register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params, bsdf_oren_nayar_prepare); register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params(), bsdf_oren_nayar_prepare);
register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params, bsdf_translucent_prepare); register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params(), bsdf_translucent_prepare);
register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params, bsdf_reflection_prepare); register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params(), bsdf_reflection_prepare);
register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params, bsdf_refraction_prepare); register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params(), bsdf_refraction_prepare);
register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params, bsdf_transparent_prepare); register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params(), bsdf_transparent_prepare);
register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params, bsdf_microfacet_ggx_prepare); register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare);
register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params, bsdf_microfacet_ggx_refraction_prepare); register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params(), bsdf_microfacet_ggx_refraction_prepare);
register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params, bsdf_microfacet_beckmann_prepare); register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params(), bsdf_microfacet_beckmann_prepare);
register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params, bsdf_microfacet_beckmann_refraction_prepare); register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params(), bsdf_microfacet_beckmann_refraction_prepare);
register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params, bsdf_ward_prepare); register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params(), bsdf_ward_prepare);
register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params, bsdf_phong_prepare); register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params(), bsdf_phong_prepare);
register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params, bsdf_phong_ramp_prepare); register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params(), bsdf_phong_ramp_prepare);
register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params, bsdf_ashikhmin_velvet_prepare); register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params(), bsdf_ashikhmin_velvet_prepare);
register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params, bsdf_westin_backscatter_prepare); register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params(), bsdf_westin_backscatter_prepare);
register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params, bsdf_westin_sheen_prepare); register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params(), bsdf_westin_sheen_prepare);
register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params, closure_bssrdf_cubic_prepare); register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params(), closure_bssrdf_cubic_prepare);
register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params, closure_emission_prepare); register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params(), closure_emission_prepare);
register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params, closure_debug_prepare); register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params(), closure_debug_prepare);
register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params, closure_background_prepare); register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params(), closure_background_prepare);
register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params, closure_holdout_prepare); register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params(), closure_holdout_prepare);
register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params, closure_subsurface_prepare); register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params(), closure_subsurface_prepare);
} }
CCL_NAMESPACE_END CCL_NAMESPACE_END

@ -64,28 +64,28 @@ enum {
OSL_CLOSURE_SUBSURFACE_ID OSL_CLOSURE_SUBSURFACE_ID
}; };
extern OSL::ClosureParam bsdf_diffuse_params[]; OSL::ClosureParam *bsdf_diffuse_params();
extern OSL::ClosureParam bsdf_oren_nayar_params[]; OSL::ClosureParam *bsdf_oren_nayar_params();
extern OSL::ClosureParam bsdf_translucent_params[]; OSL::ClosureParam *bsdf_translucent_params();
extern OSL::ClosureParam bsdf_reflection_params[]; OSL::ClosureParam *bsdf_reflection_params();
extern OSL::ClosureParam bsdf_refraction_params[]; OSL::ClosureParam *bsdf_refraction_params();
extern OSL::ClosureParam bsdf_transparent_params[]; OSL::ClosureParam *bsdf_transparent_params();
extern OSL::ClosureParam bsdf_microfacet_ggx_params[]; OSL::ClosureParam *bsdf_microfacet_ggx_params();
extern OSL::ClosureParam bsdf_microfacet_ggx_refraction_params[]; OSL::ClosureParam *bsdf_microfacet_ggx_refraction_params();
extern OSL::ClosureParam bsdf_microfacet_beckmann_params[]; OSL::ClosureParam *bsdf_microfacet_beckmann_params();
extern OSL::ClosureParam bsdf_microfacet_beckmann_refraction_params[]; OSL::ClosureParam *bsdf_microfacet_beckmann_refraction_params();
extern OSL::ClosureParam bsdf_ward_params[]; OSL::ClosureParam *bsdf_ward_params();
extern OSL::ClosureParam bsdf_phong_params[]; OSL::ClosureParam *bsdf_phong_params();
extern OSL::ClosureParam bsdf_phong_ramp_params[]; OSL::ClosureParam *bsdf_phong_ramp_params();
extern OSL::ClosureParam bsdf_ashikhmin_velvet_params[]; OSL::ClosureParam *bsdf_ashikhmin_velvet_params();
extern OSL::ClosureParam bsdf_westin_backscatter_params[]; OSL::ClosureParam *bsdf_westin_backscatter_params();
extern OSL::ClosureParam bsdf_westin_sheen_params[]; OSL::ClosureParam *bsdf_westin_sheen_params();
extern OSL::ClosureParam closure_bssrdf_cubic_params[]; OSL::ClosureParam *closure_bssrdf_cubic_params();
extern OSL::ClosureParam closure_emission_params[]; OSL::ClosureParam *closure_emission_params();
extern OSL::ClosureParam closure_debug_params[]; OSL::ClosureParam *closure_debug_params();
extern OSL::ClosureParam closure_background_params[]; OSL::ClosureParam *closure_background_params();
extern OSL::ClosureParam closure_holdout_params[]; OSL::ClosureParam *closure_holdout_params();
extern OSL::ClosureParam closure_subsurface_params[]; OSL::ClosureParam *closure_subsurface_params();
void bsdf_diffuse_prepare(OSL::RendererServices *, int id, void *data); void bsdf_diffuse_prepare(OSL::RendererServices *, int id, void *data);
void bsdf_oren_nayar_prepare(OSL::RendererServices *, int id, void *data); void bsdf_oren_nayar_prepare(OSL::RendererServices *, int id, void *data);

@ -122,14 +122,18 @@ public:
ClosureParam closure_subsurface_params[] = { ClosureParam *closure_subsurface_params()
{
static ClosureParam params[] = {
CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_eta), CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_eta),
CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_g), CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_g),
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp), CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp),
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo), CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo),
CLOSURE_STRING_KEYPARAM("label"), CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(SubsurfaceClosure) CLOSURE_FINISH_PARAM(SubsurfaceClosure)
}; };
return params;
}
CLOSURE_PREPARE(closure_subsurface_prepare, SubsurfaceClosure) CLOSURE_PREPARE(closure_subsurface_prepare, SubsurfaceClosure)