[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54430] trunk/blender/source/blender: We' ve reconsidered previous patch in IRC.

Sergey Sharybin sergey.vfx at gmail.com
Sun Feb 10 14:14:52 CET 2013


Revision: 54430
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54430
Author:   nazgul
Date:     2013-02-10 13:14:51 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
We've reconsidered previous patch in IRC.

It's more useful to completely ignore alpha for display of straight
colors.

Supporting straight pipeline is possible, but not a topic for bcon4.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h
    trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.h
    trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.cpp
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp	2013-02-10 13:14:51 UTC (rev 54430)
@@ -41,7 +41,7 @@
 	compositorOperation->setSceneName(editorNode->id->name);
 	compositorOperation->setRenderData(context->getRenderData());
 	compositorOperation->setbNodeTree(context->getbNodeTree());
-	compositorOperation->setStraightAlpha(editorNode->custom2 & 1);
+	compositorOperation->setIgnoreAlpha(editorNode->custom2 & 1);
 	imageSocket->relinkConnections(compositorOperation->getInputSocket(0), 0, graph);
 	alphaSocket->relinkConnections(compositorOperation->getInputSocket(1));
 	depthSocket->relinkConnections(compositorOperation->getInputSocket(2));

Modified: trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp	2013-02-10 13:14:51 UTC (rev 54430)
@@ -47,7 +47,7 @@
 	viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
 	viewerOperation->setCenterX(editorNode->custom3);
 	viewerOperation->setCenterY(editorNode->custom4);
-	viewerOperation->setStraightAlpha(editorNode->custom2 & 1);
+	viewerOperation->setIgnoreAlpha(editorNode->custom2 & 1);
 
 	viewerOperation->setViewSettings(context->getViewSettings());
 	viewerOperation->setDisplaySettings(context->getDisplaySettings());

Modified: trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-02-10 13:14:51 UTC (rev 54430)
@@ -49,7 +49,7 @@
 	this->m_alphaInput = NULL;
 	this->m_depthInput = NULL;
 
-	this->m_straightAlpha = false;
+	this->m_ignoreAlpha = false;
 
 	this->m_sceneName[0] = '\0';
 }
@@ -140,13 +140,15 @@
 	for (y = y1; y < y2 && (!breaked); y++) {
 		for (x = x1; x < x2 && (!breaked); x++) {
 			this->m_imageInput->read(color, x, y, COM_PS_NEAREST);
-			if (this->m_alphaInput != NULL) {
-				this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST);
+			if (this->m_ignoreAlpha) {
+				color[3] = 1.0f;
 			}
+			else {
+				if (this->m_alphaInput != NULL) {
+					this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST);
+				}
+			}
 
-			if (this->m_straightAlpha)
-				straight_to_premul_v4(color);
-
 			copy_v4_v4(buffer + offset4, color);
 
 			if (this->m_depthInput != NULL) {

Modified: trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h	2013-02-10 13:14:51 UTC (rev 54430)
@@ -66,8 +66,8 @@
 	 */
 	SocketReader *m_depthInput;
 
-	/* node input has got straight alpha which shall be premultiplied */
-	bool m_straightAlpha;
+	/* Ignore any alpha input */
+	bool m_ignoreAlpha;
 
 public:
 	CompositorOperation();
@@ -79,6 +79,6 @@
 	void deinitExecution();
 	const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
 	void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-	void setStraightAlpha(bool value) { this->m_straightAlpha = value; }
+	void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
 };
 #endif

Modified: trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp	2013-02-10 13:14:51 UTC (rev 54430)
@@ -48,7 +48,7 @@
 	this->m_doDepthBuffer = false;
 	this->m_viewSettings = NULL;
 	this->m_displaySettings = NULL;
-	this->m_straightAlpha = false;
+	this->m_ignoreAlpha = false;
 }
 
 void ViewerBaseOperation::initExecution()

Modified: trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.h	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.h	2013-02-10 13:14:51 UTC (rev 54430)
@@ -39,7 +39,7 @@
 	OrderOfChunks m_chunkOrder;
 	bool m_doDepthBuffer;
 	ImBuf *m_ibuf;
-	bool m_straightAlpha;
+	bool m_ignoreAlpha;
 
 	const ColorManagedViewSettings *m_viewSettings;
 	const ColorManagedDisplaySettings *m_displaySettings;
@@ -60,7 +60,7 @@
 	OrderOfChunks getChunkOrder() { return this->m_chunkOrder; }
 	const CompositorPriority getRenderPriority() const;
 	bool isViewerOperation() { return true; }
-	void setStraightAlpha(bool value) { this->m_straightAlpha = value; }
+	void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
 
 	void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
 	void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }

Modified: trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.cpp	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.cpp	2013-02-10 13:14:51 UTC (rev 54430)
@@ -89,18 +89,20 @@
 	for (y = y1; y < y2 && (!breaked); y++) {
 		for (x = x1; x < x2; x++) {
 			this->m_imageInput->read(&(buffer[offset4]), x, y, COM_PS_NEAREST);
-			if (this->m_alphaInput != NULL) {
-				this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST);
-				buffer[offset4 + 3] = alpha[0];
+			if (this->m_ignoreAlpha) {
+				buffer[offset4 + 3] = 1.0f;
 			}
+			else {
+				if (this->m_alphaInput != NULL) {
+					this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST);
+					buffer[offset4 + 3] = alpha[0];
+				}
+			}
 			if (m_depthInput) {
 				this->m_depthInput->read(depth, x, y, COM_PS_NEAREST);
 				depthbuffer[offset] = depth[0];
 			}
 
-			if (this->m_straightAlpha)
-				straight_to_premul_v4(buffer + offset4);
-
 			offset ++;
 			offset4 += 4;
 		}

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2013-02-10 13:14:51 UTC (rev 54430)
@@ -2656,12 +2656,12 @@
 
 static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE);
+	uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
 }
 
 static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE);
+	uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
 }
 
 static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-02-10 12:20:10 UTC (rev 54429)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-02-10 13:14:51 UTC (rev 54430)
@@ -4084,9 +4084,9 @@
 	RNA_def_property_ui_text(prop, "Y", "");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
-	prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
-	RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight");
+	prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "custom2", 1);
+	RNA_def_property_ui_text(prop, "Use Alpha", "Colors are treated alpha premultiplied, or colors output straight (alpha gets set to 1)");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
@@ -4094,9 +4094,9 @@
 {
 	PropertyRNA *prop;
 
-	prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
-	RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight");
+	prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "custom2", 1);
+	RNA_def_property_ui_text(prop, "Use Alpha", "Colors are treated alpha premultiplied, or colors output straight (alpha gets set to 1)");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 




More information about the Bf-blender-cvs mailing list