[Bf-blender-cvs] [b0dc151dc3b] temp-cycles-denoising: Cycles Denoising: Move closure classification to a separate function
Lukas Stockner
noreply at git.blender.org
Fri Apr 14 00:57:45 CEST 2017
Commit: b0dc151dc3ba866109c1b05096557fddda5dc349
Author: Lukas Stockner
Date: Fri Apr 14 00:13:44 2017 +0200
Branches: temp-cycles-denoising
https://developer.blender.org/rBb0dc151dc3ba866109c1b05096557fddda5dc349
Cycles Denoising: Move closure classification to a separate function
===================================================================
M intern/cycles/kernel/closure/bsdf.h
M intern/cycles/kernel/kernel_passes.h
M intern/cycles/kernel/svm/svm_types.h
===================================================================
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index 9139b99353a..4dea651ae4d 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -1,4 +1,4 @@
-/*
+#/*
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -379,5 +379,23 @@ 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
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index eae8e666481..989c4883e52 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -163,20 +163,10 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
if(!CLOSURE_IS_BSDF_OR_BSSRDF(sc->type))
continue;
- /* Classify closures into diffuse-like and specular-like closures.
- * This is pretty arbitrary, but some distinction has to be made. */
- bool is_specular = (sc->type == CLOSURE_BSDF_TRANSPARENT_ID);
- if(CLOSURE_IS_BSDF_MICROFACET(sc->type)) {
- MicrofacetBsdf *bsdf = (MicrofacetBsdf*) sc;
- if(bsdf->alpha_x*bsdf->alpha_y <= 0.075f*0.075f) {
- is_specular = true;
- }
- }
-
/* All closures contribute to the normal feature, but only diffuse-like ones to the albedo. */
normal += sc->N * sc->sample_weight;
sum_weight += sc->sample_weight;
- if(!is_specular) {
+ if(!bsdf_is_specular_like(sc)) {
albedo += sc->weight;
sum_nonspecular_weight += sc->sample_weight;
}
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 95920d5906c..6287e9b70a3 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -454,6 +454,7 @@ typedef enum ClosureType {
#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_HAIR_REFLECTION_ID)
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_HAIR_TRANSMISSION_ID)
#define CLOSURE_IS_BSDF_BSSRDF(type) (type == CLOSURE_BSDF_BSSRDF_ID)
+#define CLOSURE_IS_BSDF_TRANSPARENT(type) (type == CLOSURE_BSDF_TRANSPARENT_ID)
#define CLOSURE_IS_BSDF_ANISOTROPIC(type) (type >= CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID && type <= CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID)
#define CLOSURE_IS_BSDF_MULTISCATTER(type) (type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID ||\
type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID || \
More information about the Bf-blender-cvs
mailing list