Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/closure/bsdf.h
| Show All 32 Lines | |||||
| # include "kernel/closure/bssrdf.h" | # include "kernel/closure/bssrdf.h" | ||||
| #endif | #endif | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| # include "kernel/closure/volume.h" | # include "kernel/closure/volume.h" | ||||
| #endif | #endif | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Returns the square of the roughness of the closure if it has roughness, | |||||
| * 0 for singular closures and 1 otherwise. */ | |||||
| ccl_device_inline float bsdf_get_roughness_sqr(const ShaderClosure *sc) | |||||
sergey: Either call it `bsdf_get_square_roughness` which is explicit and easy to read, or follow… | |||||
| { | |||||
| if(CLOSURE_IS_BSDF_SINGULAR(sc->type)) { | |||||
| return 0.0f; | |||||
| } | |||||
| if(CLOSURE_IS_BSDF_MICROFACET(sc->type)) { | |||||
| MicrofacetBsdf *bsdf = (MicrofacetBsdf*) sc; | |||||
| return bsdf->alpha_x*bsdf->alpha_y; | |||||
| } | |||||
| return 1.0f; | |||||
| } | |||||
| ccl_device_forceinline int bsdf_sample(KernelGlobals *kg, | ccl_device_forceinline int bsdf_sample(KernelGlobals *kg, | ||||
| ShaderData *sd, | ShaderData *sd, | ||||
| const ShaderClosure *sc, | const ShaderClosure *sc, | ||||
| float randu, | float randu, | ||||
| float randv, | float randv, | ||||
| float3 *eval, | float3 *eval, | ||||
| float3 *omega_in, | float3 *omega_in, | ||||
| differential3 *domega_in, | differential3 *domega_in, | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID: | ||||
| label = volume_henyey_greenstein_sample(sc, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf); | label = volume_henyey_greenstein_sample(sc, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf); | ||||
| break; | break; | ||||
| #endif | #endif | ||||
| default: | default: | ||||
| label = LABEL_NONE; | label = LABEL_NONE; | ||||
| break; | break; | ||||
| } | } | ||||
| /* Test if BSDF sample should be treated as transparent for background. */ | |||||
| if(label & LABEL_TRANSMIT) { | |||||
| float threshold_sqr = kernel_data.background.transparent_roughness_threshold; | |||||
sergeyUnsubmitted Not Done Inline ActionsYou can not assign non-square value to a square one. Surely, kernel_data.background.transparent_roughness_threshold is likely storing squared value, but this is not what the name suggests and this line reads as a bug. sergey: You can not assign non-square value to a square one.
Surely, `kernel_data.background. | |||||
| if(threshold_sqr >= 0.0f) { | |||||
| if(bsdf_get_roughness_sqr(sc) <= threshold_sqr) { | |||||
| label |= LABEL_TRANSMIT_TRANSPARENT; | |||||
| } | |||||
| } | |||||
| } | |||||
| return label; | return label; | ||||
| } | } | ||||
| #ifndef __KERNEL_CUDA__ | #ifndef __KERNEL_CUDA__ | ||||
| ccl_device | ccl_device | ||||
| #else | #else | ||||
| ccl_device_forceinline | ccl_device_forceinline | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | #endif | ||||
| default: | default: | ||||
| return false; | return false; | ||||
| } | } | ||||
| #else | #else | ||||
| return false; | return false; | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Classifies a closure as diffuse-like or specular-like. | |||||
| * This is needed for the denoising feature pass generation, | |||||
| * which are written on the first bounce where more than 25% | |||||
| * of the sampling weight belongs to diffuse-line closures. */ | |||||
| ccl_device_inline bool bsdf_is_specular_like(ShaderClosure *sc) | |||||
| { | |||||
| if(CLOSURE_IS_BSDF_TRANSPARENT(sc->type)) { | |||||
| return true; | |||||
| } | |||||
| if(CLOSURE_IS_BSDF_MICROFACET(sc->type)) { | |||||
| MicrofacetBsdf *bsdf = (MicrofacetBsdf*) sc; | |||||
| return (bsdf->alpha_x*bsdf->alpha_y <= 0.075f*0.075f); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
Either call it bsdf_get_square_roughness which is explicit and easy to read, or follow general Blender style and use _sq.
Would really suggest the first one.