Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2017-11-05 23:43:23 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2017-11-14 06:17:54 +0300
commitd8066fb0f145395594d0a952a4c0f70206dc0214 (patch)
tree236c8d0e31f17d593cb7dba3d0430920d7893198 /intern/cycles/kernel/closure
parentf4026382116b2fbd93c5f539addd5c03db01892a (diff)
Cycles: Refactor closure roughness detection to fix a potential bug with Denoising of specular shaders
Diffstat (limited to 'intern/cycles/kernel/closure')
-rw-r--r--intern/cycles/kernel/closure/bsdf.h34
1 files changed, 16 insertions, 18 deletions
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index 0a3f9ff23fe..e4573024e85 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -36,6 +36,22 @@
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)
+{
+ 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,
ShaderData *sd,
const ShaderClosure *sc,
@@ -438,23 +454,5 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
#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