[Bf-blender-cvs] [9fb5559a0fb] master: Compositor: Display generated inputs in Viewers and Previews

Manuel Castilla noreply at git.blender.org
Tue Mar 23 12:05:28 CET 2021


Commit: 9fb5559a0fb55d8b009d0df38323798be6647a44
Author: Manuel Castilla
Date:   Tue Mar 23 12:04:34 2021 +0100
Branches: master
https://developer.blender.org/rB9fb5559a0fb55d8b009d0df38323798be6647a44

Compositor: Display generated inputs in Viewers and Previews

Currently viewers and previews only display node trees that have at least one node with fixed resolution size. When all inputs are generated, nothing is displayed in most cases (RGB Node is displayed as a single pixel on previews). By generated I mean inputs not having resolution on their own, they create content dynamically given an output resolution.

This patch adds support for those cases by using an appropriate preferred resolution on Viewers/Previews which propagates to generated inputs as output resolution. Now:
- Viewers will display generated inputs with scene render resolution.
- Previews will display them with scene aspect ratio.
This is consistent with final render result and respects relative space.

The benefit for the user is being able to compose images without any input source. For example for creating mask images or simple backgrounds.

Reviewed By: Jeroen Bakker

Differential Revision: https://developer.blender.org/D10611

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

M	release/datafiles/locale
M	release/scripts/addons
M	source/blender/compositor/intern/COM_NodeOperationBuilder.cc
M	source/blender/compositor/operations/COM_PreviewOperation.cc
M	source/blender/compositor/operations/COM_PreviewOperation.h
M	source/blender/compositor/operations/COM_ViewerOperation.cc
M	source/blender/compositor/operations/COM_ViewerOperation.h

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index ef74c1b861a..2cef4877edc 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit ef74c1b861a1b05c2483a2c045a6380704167491
+Subproject commit 2cef4877edc40875978c4e95322bb5193f5815bf
diff --git a/release/scripts/addons b/release/scripts/addons
index 6dfba915743..bcd08a9506d 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 6dfba915743b67aff99ddcc19c0807d339a87c96
+Subproject commit bcd08a9506d33bdd7358201031b04d041ef22d94
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
index 818f2e4bcf6..1c741283c7b 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
@@ -195,7 +195,9 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const
   bNodeInstanceHash *previews = m_context->getPreviewHash();
   if (previews) {
     PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(),
-                                                       m_context->getDisplaySettings());
+                                                       m_context->getDisplaySettings(),
+                                                       m_current_node->getbNode()->preview_xsize,
+                                                       m_current_node->getbNode()->preview_ysize);
     operation->setbNodeTree(m_context->getbNodeTree());
     operation->verifyPreview(previews, m_current_node->getInstanceKey());
     return operation;
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cc b/source/blender/compositor/operations/COM_PreviewOperation.cc
index eedf561717a..6d1199ab118 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cc
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cc
@@ -34,7 +34,9 @@
 #include "IMB_imbuf_types.h"
 
 PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
-                                   const ColorManagedDisplaySettings *displaySettings)
+                                   const ColorManagedDisplaySettings *displaySettings,
+                                   const unsigned int defaultWidth,
+                                   const unsigned int defaultHeight)
 
 {
   this->addInputSocket(DataType::Color, COM_SC_NO_RESIZE);
@@ -44,6 +46,8 @@ PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
   this->m_divider = 1.0f;
   this->m_viewSettings = viewSettings;
   this->m_displaySettings = displaySettings;
+  this->m_defaultWidth = defaultWidth;
+  this->m_defaultHeight = defaultHeight;
 }
 
 void PreviewOperation::verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key)
@@ -123,30 +127,33 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input,
   return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
 }
 void PreviewOperation::determineResolution(unsigned int resolution[2],
-                                           unsigned int preferredResolution[2])
+                                           unsigned int /*preferredResolution*/[2])
 {
-  NodeOperation::determineResolution(resolution, preferredResolution);
+  /* Use default preview resolution as preferred ensuring it has size so that
+   * generated inputs (which don't have resolution on their own) are displayed */
+  BLI_assert(this->m_defaultWidth > 0 && this->m_defaultHeight > 0);
+  unsigned int previewPreferredRes[2] = {this->m_defaultWidth, this->m_defaultHeight};
+  NodeOperation::determineResolution(resolution, previewPreferredRes);
 
   /* If resolution is 0 there are two possible scenarios:
    * - Either node is not connected at all
-   * - It is connected to input which doesn't have own resolution (i.e. color input).
+   * - Or it is connected to an input which has no resolution.
    *
    * In the former case we rely on the execution system to not evaluate this node.
    *
-   * For the latter case we use 1 pixel preview, so that it's possible to see preview color in the
-   * preview. This is how final F12 render will behave (flood-fill final frame with the color).
-   *
-   * Having things consistent in terms that node preview is scaled down F12 render is a very
-   * natural thing to do. */
-  int width = max_ii(1, resolution[0]);
-  int height = max_ii(1, resolution[1]);
-
+   * The latter case would only happen if an input doesn't set any resolution ignoring output
+   * preferred resolution. In such case preview size will be 0 too.
+   */
+  int width = resolution[0];
+  int height = resolution[1];
   this->m_divider = 0.0f;
-  if (width > height) {
-    this->m_divider = (float)COM_PREVIEW_SIZE / (width);
-  }
-  else {
-    this->m_divider = (float)COM_PREVIEW_SIZE / (height);
+  if (width > 0 && height > 0) {
+    if (width > height) {
+      this->m_divider = (float)COM_PREVIEW_SIZE / (width);
+    }
+    else {
+      this->m_divider = (float)COM_PREVIEW_SIZE / (height);
+    }
   }
   width = width * this->m_divider;
   height = height * this->m_divider;
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index eca50c5cda4..03ae6a6c42e 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -34,13 +34,17 @@ class PreviewOperation : public NodeOperation {
   bNodePreview *m_preview;
   SocketReader *m_input;
   float m_divider;
+  unsigned int m_defaultWidth;
+  unsigned int m_defaultHeight;
 
   const ColorManagedViewSettings *m_viewSettings;
   const ColorManagedDisplaySettings *m_displaySettings;
 
  public:
   PreviewOperation(const ColorManagedViewSettings *viewSettings,
-                   const ColorManagedDisplaySettings *displaySettings);
+                   const ColorManagedDisplaySettings *displaySettings,
+                   unsigned int defaultWidth,
+                   unsigned int defaultHeight);
   void verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key);
 
   bool isOutputOperation(bool /*rendering*/) const
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc
index e31f7ad8eba..ea5937d8afb 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cc
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cc
@@ -118,6 +118,17 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
   updateImage(rect);
 }
 
+void ViewerOperation::determineResolution(unsigned int resolution[2],
+                                          unsigned int /*preferredResolution*/[2])
+{
+  const int sceneRenderWidth = this->m_rd->xsch * this->m_rd->size / 100;
+  const int sceneRenderHeight = this->m_rd->ysch * this->m_rd->size / 100;
+
+  unsigned int localPrefRes[2] = {static_cast<unsigned int>(sceneRenderWidth),
+                                  static_cast<unsigned int>(sceneRenderHeight)};
+  NodeOperation::determineResolution(resolution, localPrefRes);
+}
+
 void ViewerOperation::initImage()
 {
   Image *ima = this->m_image;
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index b4a7fbb4f4b..513c6eae487 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -51,6 +51,7 @@ class ViewerOperation : public NodeOperation {
   void initExecution();
   void deinitExecution();
   void executeRegion(rcti *rect, unsigned int tileNumber);
+  void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
   bool isOutputOperation(bool /*rendering*/) const
   {
     if (G.background) {



More information about the Bf-blender-cvs mailing list