[Bf-blender-cvs] [87b4dec2823] compositor-anti-aliasing: Compositor anti-aliasing: map values between 0 and 1

Habib Gahbiche noreply at git.blender.org
Sun Feb 28 17:45:08 CET 2021


Commit: 87b4dec2823bd515de797be77be8ea81aa6d099e
Author: Habib Gahbiche
Date:   Sun Feb 28 12:20:46 2021 +0100
Branches: compositor-anti-aliasing
https://developer.blender.org/rB87b4dec2823bd515de797be77be8ea81aa6d099e

Compositor anti-aliasing: map values between 0 and 1

expose values in ranges between 0 and 1 to user

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

M	source/blender/compositor/operations/COM_SMAAOperation.cpp
M	source/blender/compositor/operations/COM_SMAAOperation.h
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/composite/nodes/node_composite_antialiasing.c

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

diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cpp b/source/blender/compositor/operations/COM_SMAAOperation.cpp
index 9005c49bfe2..01541cbf2f6 100644
--- a/source/blender/compositor/operations/COM_SMAAOperation.cpp
+++ b/source/blender/compositor/operations/COM_SMAAOperation.cpp
@@ -175,6 +175,17 @@ void SMAAEdgeDetectionOperation::deinitExecution()
 	this->m_valueReader = NULL;
 }
 
+void SMAAEdgeDetectionOperation::setThreshold(float threshold)
+{
+	m_threshold = threshold * 0.5;
+}
+
+void SMAAEdgeDetectionOperation::setLocalContrastAdaptationFactor(float factor)
+{
+	// todo (habib): replace with generic interval mapping function, e.g. from BLI_
+	m_local_contrast_adaptation_factor = (factor * 9) + 1;
+}
+
 bool SMAAEdgeDetectionOperation::determineDependingAreaOfInterest(rcti *input,
 								  ReadBufferOperation *readOperation, rcti *output)
 {
@@ -398,6 +409,11 @@ void SMAABlendingWeightCalculationOperation::initExecution()
 	this->m_imageReader = this->getInputSocketReader(0);
 }
 
+void SMAABlendingWeightCalculationOperation::setCornerRounding(float rounding)
+{
+	m_corner_rounding = static_cast<int>(rounding * 100);
+}
+
 void SMAABlendingWeightCalculationOperation::executePixel(float output[4], int x, int y, void */*data*/)
 {
 	float edges[4], c[4];
diff --git a/source/blender/compositor/operations/COM_SMAAOperation.h b/source/blender/compositor/operations/COM_SMAAOperation.h
index d8468bdeca3..a48bbdef27c 100644
--- a/source/blender/compositor/operations/COM_SMAAOperation.h
+++ b/source/blender/compositor/operations/COM_SMAAOperation.h
@@ -50,8 +50,14 @@ public:
 	 */
 	void deinitExecution();
 
-	void setThreshold(float threshold) { m_threshold = threshold; }
-	void setLocalContrastAdaptationFactor(float factor) { m_local_contrast_adaptation_factor = factor; }
+	/**
+	 * map from [0, 1] to [0, 0.5]
+	 */
+	void setThreshold(float threshold);
+	/**
+	 * map to [0, 1] to [1, 10]
+	 */
+	void setLocalContrastAdaptationFactor(float factor);
 
 	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
 };
@@ -99,7 +105,10 @@ public:
 	 */
 	void deinitExecution();
 
-	void setCornerRounding(int rounding) { m_corner_rounding = rounding; }
+	/**
+	 * Map from [0, 1] to [0, 100]
+	 */
+	void setCornerRounding(float rounding);
 
 	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
 private:
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 0c9684afbae..01b9812b56d 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -719,9 +719,10 @@ typedef struct NodeAntiAliasingData {
   float thresh;
   float val_thresh;
   float adapt_fac;
-  short rounding;
+  float rounding;
   char detect_type;
   char corner;
+  char _pad[2];
 } NodeAntiAliasingData;
 
 /* NOTE: Only for do-version code. */
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 16a9345b1de..28cef12baed 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8444,20 +8444,21 @@ static void def_cmp_antialiasing(StructRNA *srna)
 
 	prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_UNSIGNED);
 	RNA_def_property_float_sdna(prop, NULL, "thresh");
-	RNA_def_property_ui_range(prop, 0.0f, 0.5f, 1.0, 3);
+	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
 	RNA_def_property_ui_text(prop, "Threshold", "Threshold to detect edges (smaller threshold makes more sensitive detection)");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
 	prop = RNA_def_property(srna, "local_contrast_adaptation_factor", PROP_FLOAT, PROP_UNSIGNED);
 	RNA_def_property_float_sdna(prop, NULL, "adapt_fac");
-	RNA_def_property_range(prop, 1.0f, FLT_MAX);
-	RNA_def_property_ui_range(prop, 1.0f, 10.0f, 1.0, 3);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
 	RNA_def_property_ui_text(prop, "Local Contrast Adaptation Factor", "How much to eliminate spurious edges to avoid artifacts (the larger value makes less active; the value 2.0, for example, means discard a detected edge if there is a neighboring edge that has 2.0 times bigger contrast than the current one)");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
-	prop = RNA_def_property(srna, "corner_rounding", PROP_INT, PROP_UNSIGNED);
-	RNA_def_property_int_sdna(prop, NULL, "rounding");
-	RNA_def_property_range(prop, 0, 100);
+	prop = RNA_def_property(srna, "corner_rounding", PROP_FLOAT, PROP_UNSIGNED);
+	RNA_def_property_float_sdna(prop, NULL, "rounding");
+  RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
 	RNA_def_property_ui_text(prop, "Corner Rounding", "How much sharp corners will be rounded");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.c b/source/blender/nodes/composite/nodes/node_composite_antialiasing.c
index 372a6f3fc06..557a1d78fa3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.c
+++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.c
@@ -49,11 +49,11 @@ static void node_composit_init_antialiasing(bNodeTree *UNUSED(ntree), bNode *nod
   NodeAntiAliasingData *data = MEM_callocN(sizeof(NodeAntiAliasingData), "node antialiasing data");
 
   data->detect_type = CMP_NODE_ANTIALIASING_COLOR;
-  data->thresh = 0.5f;
+  data->thresh = 1;// 0.5f;
   data->val_thresh = 0.1f;
-  data->adapt_fac = 2.0f;
+  data->adapt_fac = 0.2; // 2.0f;
   data->corner = true;
-  data->rounding = 25;
+  data->rounding = 0.25; // 25;
 
   node->storage = data;
 }



More information about the Bf-blender-cvs mailing list