diff options
Diffstat (limited to 'intern/cycles/kernel/svm/svm_closure.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_closure.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index b5bd2b42cb4..72e6a047158 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -25,6 +25,7 @@ __device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, if(type == CLOSURE_BSDF_SHARP_GLASS_ID) { if(refract) { sc->data0 = eta; + sc->data1 = 0.0f; sd->flag |= bsdf_refraction_setup(sc); } else @@ -58,6 +59,9 @@ __device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, Clo if(sd->num_closure < MAX_CLOSURE) { sc->weight *= mix_weight; sc->type = type; +#ifdef __OSL__ + sc->prim = NULL; +#endif sd->num_closure++; return sc; } @@ -79,6 +83,9 @@ __device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float m sc->weight = weight; sc->sample_weight = sample_weight; sd->num_closure++; +#ifdef __OSL__ + sc->prim = NULL; +#endif return sc; } @@ -125,10 +132,13 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st float roughness = param1; if(roughness == 0.0f) { + sc->data0 = 0.0f; + sc->data1 = 0.0f; sd->flag |= bsdf_diffuse_setup(sc); } else { sc->data0 = roughness; + sc->data1 = 0.0f; sd->flag |= bsdf_oren_nayar_setup(sc); } } @@ -138,6 +148,8 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight); if(sc) { + sc->data0 = 0.0f; + sc->data1 = 0.0f; sc->N = N; sd->flag |= bsdf_translucent_setup(sc); } @@ -147,6 +159,8 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st ShaderClosure *sc = svm_node_closure_get_bsdf(sd, mix_weight); if(sc) { + sc->data0 = 0.0f; + sc->data1 = 0.0f; sc->N = N; sd->flag |= bsdf_transparent_setup(sc); } @@ -164,6 +178,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st if(sc) { sc->N = N; sc->data0 = param1; + sc->data1 = 0.0f; /* setup bsdf */ if(type == CLOSURE_BSDF_REFLECTION_ID) @@ -302,10 +317,73 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st /* sigma */ sc->data0 = clamp(param1, 0.0f, 1.0f); + sc->data1 = 0.0f; sd->flag |= bsdf_ashikhmin_velvet_setup(sc); } break; } +#ifdef __SUBSURFACE__ + case CLOSURE_BSSRDF_ID: { + ShaderClosure *sc = &sd->closure[sd->num_closure]; + float3 weight = sc->weight * mix_weight; + float sample_weight = fabsf(average(weight)); + + if(sample_weight > 1e-5f && sd->num_closure+2 < MAX_CLOSURE) { + /* radius * scale */ + float3 radius = stack_load_float3(stack, data_node.w)*param1; + /* index of refraction */ + float eta = fmaxf(param2, 1.0f + 1e-5f); + + /* create one closure per color channel */ + if(fabsf(weight.x) > 0.0f) { + sc->weight = make_float3(weight.x, 0.0f, 0.0f); + sc->sample_weight = sample_weight; + sc->data0 = radius.x; + sc->data1 = eta; +#ifdef __OSL__ + sc->prim = NULL; +#endif + sc->N = N; + sd->flag |= bssrdf_setup(sc); + + sd->num_closure++; + sc++; + } + + if(fabsf(weight.y) > 0.0f) { + sc->weight = make_float3(0.0f, weight.y, 0.0f); + sc->sample_weight = sample_weight; + sc->data0 = radius.y; + sc->data1 = eta; +#ifdef __OSL__ + sc->prim = NULL; +#endif + sc->N = N; + sd->flag |= bssrdf_setup(sc); + + sd->num_closure++; + sc++; + } + + if(fabsf(weight.z) > 0.0f) { + sc->weight = make_float3(0.0f, 0.0f, weight.z); + sc->sample_weight = sample_weight; + sc->data0 = radius.z; + sc->data1 = eta; +#ifdef __OSL__ + sc->prim = NULL; +#endif + sc->N = N; + sd->flag |= bssrdf_setup(sc); + + sd->num_closure++; + sc++; + } + } + + break; + } +#endif default: break; } |