diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-08 18:14:04 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-08 18:56:11 +0300 |
commit | 29d2ff7b31aef4fe490446e8a82fdc34021e2592 (patch) | |
tree | d78dfbd14e6b0c87fa0b909dc86a2bc77e10680b /intern/cycles/kernel/osl/osl_bssrdf.cpp | |
parent | aabafece03fee807d6b9e5e6d40273f70cc4b9d8 (diff) |
Cycles: unify OSL BSSRDF closure into a single bssrdf() closure with method.
This is similar to the upstream unified microfacet() closure, and makes it
easier to extend in the future.
Diffstat (limited to 'intern/cycles/kernel/osl/osl_bssrdf.cpp')
-rw-r--r-- | intern/cycles/kernel/osl/osl_bssrdf.cpp | 133 |
1 files changed, 40 insertions, 93 deletions
diff --git a/intern/cycles/kernel/osl/osl_bssrdf.cpp b/intern/cycles/kernel/osl/osl_bssrdf.cpp index 3e7905f26df..db6426f60e5 100644 --- a/intern/cycles/kernel/osl/osl_bssrdf.cpp +++ b/intern/cycles/kernel/osl/osl_bssrdf.cpp @@ -48,9 +48,38 @@ CCL_NAMESPACE_BEGIN using namespace OSL; +static ustring u_cubic("cubic"); +static ustring u_gaussian("gaussian"); +static ustring u_burley("burley"); +static ustring u_principled("principled"); + class CBSSRDFClosure : public CClosurePrimitive { public: Bssrdf params; + ustring method; + + CBSSRDFClosure() + { + params.texture_blur = 0.0f; + params.sharpness = 0.0f; + params.roughness = 0.0f; + } + + void setup(ShaderData *sd, int path_flag, float3 weight) + { + if (method == u_cubic) { + alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID); + } + else if (method == u_gaussian) { + alloc(sd, path_flag, weight, CLOSURE_BSSRDF_GAUSSIAN_ID); + } + else if (method == u_burley) { + alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID); + } + else if (method == u_principled) { + alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID); + } + } void alloc(ShaderData *sd, int path_flag, float3 weight, ClosureType type) { @@ -76,105 +105,23 @@ public: } }; -/* Cubic */ - -class CubicBSSRDFClosure : public CBSSRDFClosure { -public: - void setup(ShaderData *sd, int path_flag, float3 weight) - { - alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID); - } -}; - -ClosureParam *closure_bssrdf_cubic_params() -{ - static ClosureParam params[] = { - CLOSURE_FLOAT3_PARAM(CubicBSSRDFClosure, params.N), - CLOSURE_FLOAT3_PARAM(CubicBSSRDFClosure, params.radius), - CLOSURE_FLOAT_PARAM(CubicBSSRDFClosure, params.texture_blur), - CLOSURE_FLOAT_PARAM(CubicBSSRDFClosure, params.sharpness), - CLOSURE_STRING_KEYPARAM(CubicBSSRDFClosure, label, "label"), - CLOSURE_FINISH_PARAM(CubicBSSRDFClosure) - }; - return params; -} - -CCLOSURE_PREPARE(closure_bssrdf_cubic_prepare, CubicBSSRDFClosure) - -/* Gaussian */ - -class GaussianBSSRDFClosure : public CBSSRDFClosure { -public: - void setup(ShaderData *sd, int path_flag, float3 weight) - { - alloc(sd, path_flag, weight, CLOSURE_BSSRDF_GAUSSIAN_ID); - } -}; - -ClosureParam *closure_bssrdf_gaussian_params() -{ - static ClosureParam params[] = { - CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, params.N), - CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, params.radius), - CLOSURE_FLOAT_PARAM(GaussianBSSRDFClosure, params.texture_blur), - CLOSURE_STRING_KEYPARAM(GaussianBSSRDFClosure, label, "label"), - CLOSURE_FINISH_PARAM(GaussianBSSRDFClosure) - }; - return params; -} - -CCLOSURE_PREPARE(closure_bssrdf_gaussian_prepare, GaussianBSSRDFClosure) - -/* Burley */ - -class BurleyBSSRDFClosure : public CBSSRDFClosure { -public: - void setup(ShaderData *sd, int path_flag, float3 weight) - { - alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID); - } -}; - -ClosureParam *closure_bssrdf_burley_params() -{ - static ClosureParam params[] = { - CLOSURE_FLOAT3_PARAM(BurleyBSSRDFClosure, params.N), - CLOSURE_FLOAT3_PARAM(BurleyBSSRDFClosure, params.radius), - CLOSURE_FLOAT_PARAM(BurleyBSSRDFClosure, params.texture_blur), - CLOSURE_FLOAT3_PARAM(BurleyBSSRDFClosure, params.albedo), - CLOSURE_STRING_KEYPARAM(BurleyBSSRDFClosure, label, "label"), - CLOSURE_FINISH_PARAM(BurleyBSSRDFClosure) - }; - return params; -} - -CCLOSURE_PREPARE(closure_bssrdf_burley_prepare, BurleyBSSRDFClosure) - -/* Disney principled */ - -class PrincipledBSSRDFClosure : public CBSSRDFClosure { -public: - void setup(ShaderData *sd, int path_flag, float3 weight) - { - alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID); - } -}; - -ClosureParam *closure_bssrdf_principled_params() +ClosureParam *closure_bssrdf_params() { static ClosureParam params[] = { - CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, params.N), - CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, params.radius), - CLOSURE_FLOAT_PARAM(PrincipledBSSRDFClosure, params.texture_blur), - CLOSURE_FLOAT3_PARAM(PrincipledBSSRDFClosure, params.albedo), - CLOSURE_FLOAT_PARAM(PrincipledBSSRDFClosure, params.roughness), - CLOSURE_STRING_KEYPARAM(PrincipledBSSRDFClosure, label, "label"), - CLOSURE_FINISH_PARAM(PrincipledBSSRDFClosure) + CLOSURE_STRING_PARAM(CBSSRDFClosure, method), + CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.N), + CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.radius), + CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.albedo), + CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, params.texture_blur, "texture_blur"), + CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, params.sharpness, "sharpness"), + CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, params.roughness, "roughness"), + CLOSURE_STRING_KEYPARAM(CBSSRDFClosure, label, "label"), + CLOSURE_FINISH_PARAM(CBSSRDFClosure) }; return params; } -CCLOSURE_PREPARE(closure_bssrdf_principled_prepare, PrincipledBSSRDFClosure) +CCLOSURE_PREPARE(closure_bssrdf_prepare, CBSSRDFClosure) CCL_NAMESPACE_END |