diff options
author | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-09-16 03:58:00 +0400 |
---|---|---|
committer | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-09-16 03:58:00 +0400 |
commit | 3306afac876b545d85b121ea1bc7539d5c759d94 (patch) | |
tree | 776bcec11cd821a8bd2f3c73e8f306b9a06c2838 /intern/cycles/kernel/osl | |
parent | 0e46f1b1f8ceda9b2705691fbc82ac254de78aee (diff) |
Cycles Hair: Two basic bair shaders added
A new hair bsdf node, with two closure options, is added. These closures allow the generation of the reflective and transmission components of hair. The node allows control of the highlight colour, roughness and angular shift.
Llimitations include:
-No glint or fresnel adjustments.
-The 'offset' is un-used when triangle primitives are used.
Diffstat (limited to 'intern/cycles/kernel/osl')
-rw-r--r-- | intern/cycles/kernel/osl/osl_closures.cpp | 32 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/osl_shader.cpp | 4 |
2 files changed, 36 insertions, 0 deletions
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 6a3f27fb7b1..221406a1716 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -54,6 +54,7 @@ #include "closure/bsdf_ward.h" #include "closure/bsdf_westin.h" #include "closure/bsdf_toon.h" +#include "closure/bsdf_hair.h" CCL_NAMESPACE_BEGIN @@ -142,6 +143,32 @@ BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannRefraction, microfacet_beckmann_refra CLOSURE_FLOAT_PARAM(MicrofacetBeckmannRefractionClosure, sc.data1), BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannRefraction, microfacet_beckmann_refraction) +BSDF_CLOSURE_CLASS_BEGIN(HairReflection, hair_reflection, hair_reflection, LABEL_GLOSSY) + CLOSURE_FLOAT3_PARAM(HairReflectionClosure, sc.N), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.data0), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.data1), +#ifdef __HAIR__ + CLOSURE_FLOAT3_PARAM(HairReflectionClosure, sc.T), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.offset), +#else + CLOSURE_FLOAT3_PARAM(HairReflectionClosure, sc.N), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.data1), +#endif +BSDF_CLOSURE_CLASS_END(HairReflection, hair_reflection) + +BSDF_CLOSURE_CLASS_BEGIN(HairTransmission, hair_transmission, hair_transmission, LABEL_GLOSSY) + CLOSURE_FLOAT3_PARAM(HairTransmissionClosure, sc.N), + CLOSURE_FLOAT_PARAM(HairTransmissionClosure, sc.data0), + CLOSURE_FLOAT_PARAM(HairTransmissionClosure, sc.data1), +#ifdef __HAIR__ + CLOSURE_FLOAT3_PARAM(HairReflectionClosure, sc.T), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.offset), +#else + CLOSURE_FLOAT3_PARAM(HairReflectionClosure, sc.N), + CLOSURE_FLOAT_PARAM(HairReflectionClosure, sc.data1), +#endif +BSDF_CLOSURE_CLASS_END(HairTransmission, hair_transmission) + /* Registration */ static void generic_closure_setup(OSL::RendererServices *, int id, void *data) @@ -225,6 +252,11 @@ void OSLShader::register_closures(OSLShadingSystem *ss_) closure_bssrdf_cubic_extended_params(), closure_bssrdf_cubic_prepare); register_closure(ss, "bssrdf_gaussian", id++, closure_bssrdf_gaussian_extended_params(), closure_bssrdf_gaussian_prepare); + + register_closure(ss, "hair_reflection", id++, + bsdf_hair_reflection_params(), bsdf_hair_reflection_prepare); + register_closure(ss, "hair_transmission", id++, + bsdf_hair_transmission_params(), bsdf_hair_transmission_prepare); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index 9ff3797b50f..625ad263f7f 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -180,6 +180,10 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag, sc.data1 = bsdf->sc.data1; sc.prim = bsdf->sc.prim; +#ifdef __HAIR__ + sc.offset = bsdf->sc.offset; +#endif + /* add */ if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) { sd->closure[sd->num_closure++] = sc; |