Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_shader.h
| Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ccl_device_forceinline bool _shader_bsdf_exclude(ClosureType type, uint light_shader_flags) | ccl_device_forceinline bool _shader_bsdf_exclude(ClosureType type, uint light_shader_flags) | ||||
| { | { | ||||
| if (!(light_shader_flags & SHADER_EXCLUDE_ANY)) { | if (!(light_shader_flags & SHADER_EXCLUDE_ANY)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (light_shader_flags & SHADER_EXCLUDE_DIFFUSE) { | if (light_shader_flags & SHADER_EXCLUDE_DIFFUSE) { | ||||
| if (CLOSURE_IS_BSDF_DIFFUSE(type) || CLOSURE_IS_BSDF_BSSRDF(type)) { | if (CLOSURE_IS_BSDF_DIFFUSE(type)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| if (light_shader_flags & SHADER_EXCLUDE_GLOSSY) { | if (light_shader_flags & SHADER_EXCLUDE_GLOSSY) { | ||||
| if (CLOSURE_IS_BSDF_GLOSSY(type)) { | if (CLOSURE_IS_BSDF_GLOSSY(type)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| Show All 25 Lines | for (int i = 0; i < sd->num_closure; i++) { | ||||
| } | } | ||||
| if (CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) { | if (CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) { | ||||
| if (CLOSURE_IS_BSDF(sc->type) && !_shader_bsdf_exclude(sc->type, light_shader_flags)) { | if (CLOSURE_IS_BSDF(sc->type) && !_shader_bsdf_exclude(sc->type, light_shader_flags)) { | ||||
| float bsdf_pdf = 0.0f; | float bsdf_pdf = 0.0f; | ||||
| float3 eval = bsdf_eval(kg, sd, sc, omega_in, is_transmission, &bsdf_pdf); | float3 eval = bsdf_eval(kg, sd, sc, omega_in, is_transmission, &bsdf_pdf); | ||||
| if (bsdf_pdf != 0.0f) { | if (bsdf_pdf != 0.0f) { | ||||
| const bool is_diffuse = (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || | const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type); | ||||
| CLOSURE_IS_BSDF_BSSRDF(sc->type)); | |||||
| bsdf_eval_accum(result_eval, is_diffuse, eval * sc->weight, 1.0f); | bsdf_eval_accum(result_eval, is_diffuse, eval * sc->weight, 1.0f); | ||||
| sum_pdf += bsdf_pdf * sc->sample_weight; | sum_pdf += bsdf_pdf * sc->sample_weight; | ||||
| } | } | ||||
| } | } | ||||
| sum_sample_weight += sc->sample_weight; | sum_sample_weight += sc->sample_weight; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | ccl_device int shader_bsdf_sample_closure(const KernelGlobals *kg, | ||||
| int label; | int label; | ||||
| float3 eval = zero_float3(); | float3 eval = zero_float3(); | ||||
| *pdf = 0.0f; | *pdf = 0.0f; | ||||
| label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); | label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); | ||||
| if (*pdf != 0.0f) { | if (*pdf != 0.0f) { | ||||
| const bool is_diffuse = (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || | const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type); | ||||
| CLOSURE_IS_BSDF_BSSRDF(sc->type)); | |||||
| bsdf_eval_init(bsdf_eval, is_diffuse, eval * sc->weight); | bsdf_eval_init(bsdf_eval, is_diffuse, eval * sc->weight); | ||||
| if (sd->num_closure > 1) { | if (sd->num_closure > 1) { | ||||
| const bool is_transmission = shader_bsdf_is_transmission(sd, *omega_in); | const bool is_transmission = shader_bsdf_is_transmission(sd, *omega_in); | ||||
| float sweight = sc->sample_weight; | float sweight = sc->sample_weight; | ||||
| *pdf = _shader_bsdf_multi_eval( | *pdf = _shader_bsdf_multi_eval( | ||||
| kg, sd, *omega_in, is_transmission, sc, bsdf_eval, *pdf * sweight, sweight, 0); | kg, sd, *omega_in, is_transmission, sc, bsdf_eval, *pdf * sweight, sweight, 0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| ccl_device float3 shader_bsdf_diffuse(const KernelGlobals *kg, const ShaderData *sd) | ccl_device float3 shader_bsdf_diffuse(const KernelGlobals *kg, const ShaderData *sd) | ||||
| { | { | ||||
| float3 eval = zero_float3(); | float3 eval = zero_float3(); | ||||
| for (int i = 0; i < sd->num_closure; i++) { | for (int i = 0; i < sd->num_closure; i++) { | ||||
| const ShaderClosure *sc = &sd->closure[i]; | const ShaderClosure *sc = &sd->closure[i]; | ||||
| if (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || CLOSURE_IS_BSSRDF(sc->type) || | if (CLOSURE_IS_BSDF_DIFFUSE(sc->type) || CLOSURE_IS_BSSRDF(sc->type)) | ||||
| CLOSURE_IS_BSDF_BSSRDF(sc->type)) | |||||
| eval += sc->weight; | eval += sc->weight; | ||||
| } | } | ||||
| return eval; | return eval; | ||||
| } | } | ||||
| ccl_device float3 shader_bsdf_glossy(const KernelGlobals *kg, const ShaderData *sd) | ccl_device float3 shader_bsdf_glossy(const KernelGlobals *kg, const ShaderData *sd) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 450 Lines • Show Last 20 Lines | |||||