[Bf-blender-cvs] [51c1c36] soc-2016-cycles_denoising: Cycles: Cleanup - use an enum instead of hardcoded types, scale data passes by scale

Lukas Stockner noreply at git.blender.org
Fri Jun 24 23:33:09 CEST 2016


Commit: 51c1c3636a83f94cd202fd9a49e7053781f82306
Author: Lukas Stockner
Date:   Tue Jun 21 19:21:16 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rB51c1c3636a83f94cd202fd9a49e7053781f82306

Cycles: Cleanup - use an enum instead of hardcoded types, scale data passes by scale

This commit turns the extended pass types into an enum for nicer code.
Also, the feature passes are now scaled like the regular ones, which means that the passes
are shown correctly in the Image editor.

===================================================================

M	intern/cycles/render/buffers.cpp
M	intern/cycles/render/buffers.h

===================================================================

diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 01dd8e5..4878ce9 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -186,22 +186,23 @@ bool RenderBuffers::get_denoising_rect(int type, float exposure, int sample, int
 	if(!params.denoising_passes)
 		/* The RenderBuffer doesn't have denoising passes. */
 		return false;
-	if(!(type & 0b111111111))
+	if(!(type & EX_TYPE_DENOISE_ALL))
 		/* The type doesn't correspond to any denoising pass. */
 		return false;
 
 	float scale = 1.0f;
 	int type_offset = 0;
 	switch(type) {
-		case (1 << 0): break;
-		case (1 << 1): type_offset =  3; break;
-		case (1 << 2): type_offset =  6; break;
-		case (1 << 3): type_offset =  9; break;
-		case (1 << 4): type_offset = 12; break;
-		case (1 << 5): type_offset = 13; break;
-		case (1 << 6): type_offset = 14; scale = exposure; break;
-		case (1 << 7): type_offset = 17; scale = exposure*exposure; break;
-		case (1 << 8): type_offset = 20; scale = exposure/sample; break;
+		case EX_TYPE_NONE: assert(0); break;
+		case EX_TYPE_DENOISE_NORMAL:     type_offset =  0; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_NORMAL_VAR: type_offset =  3; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_ALBEDO:     type_offset =  6; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_ALBEDO_VAR: type_offset =  9; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_DEPTH:      type_offset = 12; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_DEPTH_VAR:  type_offset = 13; scale = 1.0f/sample; break;
+		case EX_TYPE_DENOISE_NOISY:      type_offset = 14; scale = exposure/sample; break;
+		case EX_TYPE_DENOISE_NOISY_VAR:  type_offset = 17; scale = exposure*exposure/sample; break;
+		case EX_TYPE_DENOISE_CLEAN:      type_offset = 20; scale = exposure/sample; break;
 	}
 
 	int pass_offset = params.get_denoise_offset() + type_offset;
@@ -214,13 +215,13 @@ bool RenderBuffers::get_denoising_rect(int type, float exposure, int sample, int
                           for(int x = params.overscan; x < params.width - params.overscan; x++, in += pass_stride, pixels += components)
 
 	if(components == 1) {
-		assert(type & 0b110000);
+		assert(type & (EX_TYPE_DENOISE_DEPTH | EX_TYPE_DENOISE_DEPTH_VAR));
 		FOREACH_PIXEL
 			pixels[0] = *in;
 	}
 	else {
 		assert(components == 3);
-		assert(!(type & 0b110000));
+		assert(!(type & (EX_TYPE_DENOISE_DEPTH | EX_TYPE_DENOISE_DEPTH_VAR)));
 
 		FOREACH_PIXEL {
 			pixels[0] = in[0] * scale;
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index 292ea27..c1de2f6 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -30,6 +30,29 @@
 
 CCL_NAMESPACE_BEGIN
 
+typedef enum DenoiseExtendedTypes {
+	EX_TYPE_NONE                      = 0,
+	EX_TYPE_DENOISE_NORMAL            = (1 << 0),
+	EX_TYPE_DENOISE_NORMAL_VAR        = (1 << 1),
+	EX_TYPE_DENOISE_ALBEDO            = (1 << 2),
+	EX_TYPE_DENOISE_ALBEDO_VAR        = (1 << 3),
+	EX_TYPE_DENOISE_DEPTH             = (1 << 4),
+	EX_TYPE_DENOISE_DEPTH_VAR         = (1 << 5),
+	EX_TYPE_DENOISE_NOISY             = (1 << 6),
+	EX_TYPE_DENOISE_NOISY_VAR         = (1 << 7),
+	EX_TYPE_DENOISE_CLEAN             = (1 << 8),
+
+	EX_TYPE_DENOISE_REQUIRED = (EX_TYPE_DENOISE_NORMAL
+	                          | EX_TYPE_DENOISE_NORMAL_VAR
+	                          | EX_TYPE_DENOISE_ALBEDO
+	                          | EX_TYPE_DENOISE_ALBEDO_VAR
+	                          | EX_TYPE_DENOISE_DEPTH
+	                          | EX_TYPE_DENOISE_DEPTH_VAR
+	                          | EX_TYPE_DENOISE_NOISY
+	                          | EX_TYPE_DENOISE_NOISY_VAR),
+	EX_TYPE_DENOISE_ALL = EX_TYPE_DENOISE_REQUIRED | EX_TYPE_DENOISE_CLEAN,
+} DenoiseExtendedTypes;
+
 class Device;
 struct DeviceDrawParams;
 struct float4;




More information about the Bf-blender-cvs mailing list