From 66df8fff328079615dfa222eb7409826a785d6a9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 10 Jul 2020 11:31:16 +0200 Subject: Compositor: Fix calculation of preview resolution Were two issues: - Divider was calculated in integer domain, causing rounding issues in general case, and causing singularity in a corner case when input is smaller than the preview size. - The resolution was scaled down by 1 pixel for no obvious reason. --- source/blender/compositor/operations/COM_PreviewOperation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 30fe2ca824d..07bf534cd74 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -130,10 +130,10 @@ void PreviewOperation::determineResolution(unsigned int resolution[2], int height = resolution[1]; this->m_divider = 0.0f; if (width > height) { - this->m_divider = COM_PREVIEW_SIZE / (width - 1); + this->m_divider = (float)COM_PREVIEW_SIZE / (width); } else { - this->m_divider = COM_PREVIEW_SIZE / (height - 1); + this->m_divider = (float)COM_PREVIEW_SIZE / (height); } width = width * this->m_divider; height = height * this->m_divider; -- cgit v1.2.3 From 83f01db7a96c6e86b22b1b28e9873b1c18f0a66a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 10 Jul 2020 11:37:51 +0200 Subject: Compositor: Fix node preview when input resolution is not known The final render will use scene resolution in this case. For example, when Color Input is plugger to preview and composite output nodes, final render will flood-fill the final image which is a size of scene resolution with this color. Before this fix the node preview was empty. After this fix the node preview will be flood-filled with the color. Fixes T78586 Differential Revision: https://developer.blender.org/D8263 --- .../compositor/operations/COM_PreviewOperation.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 07bf534cd74..43d20271141 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -126,8 +126,21 @@ void PreviewOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) { NodeOperation::determineResolution(resolution, preferredResolution); - int width = resolution[0]; - int height = resolution[1]; + + /* 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). + * + * 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]); + this->m_divider = 0.0f; if (width > height) { this->m_divider = (float)COM_PREVIEW_SIZE / (width); -- cgit v1.2.3