Compositor: Match size of Fast Gaussian with Gaussian #121211

Merged
Omar Emara merged 4 commits from OmarEmaraDev/blender:fast-gaussian-match-size into main 2024-05-01 09:02:05 +02:00
3 changed files with 35 additions and 3 deletions
Showing only changes of commit f2c9514106 - Show all commits

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */ /* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION #define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 23 #define BLENDER_FILE_SUBVERSION 24
/* Minimum Blender version that supports reading file written with the current /* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to * version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -3241,6 +3241,34 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
} }
} }
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 24)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type != NTREE_COMPOSIT) {
continue;
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type != CMP_NODE_BLUR) {
continue;
}
NodeBlurData &blur_data = *static_cast<NodeBlurData *>(node->storage);
if (blur_data.filtertype != R_FILTER_FAST_GAUSS) {
continue;
}
/* The side of the Fast Gaussian mode of blur decrease by the following factor to match
* other blur sizes. So increase it back. */
const float size_factor = 3.0f / 2.0f;
blur_data.sizex *= size_factor;
blur_data.sizey *= size_factor;
blur_data.percentx *= size_factor;
blur_data.percenty *= size_factor;
}
}
FOREACH_NODETREE_END;
}
/** /**
* Always bump subversion in BKE_blender_version.h when adding versioning * Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check. * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -17,8 +17,12 @@ FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(DataT
void FastGaussianBlurOperation::init_data() void FastGaussianBlurOperation::init_data()
{ {
BlurBaseOperation::init_data(); BlurBaseOperation::init_data();
sigma_x_ = data_.sizex * size_ / 2.0f;
sigma_y_ = data_.sizey * size_ / 2.0f; /* Compute the Gaussian sigma from the radius, where the radius is in pixels. Blender's filter is
* truncated at |x| > 3 * sigma as can be seen in the R_FILTER_GAUSS case of the RE_filter_value
* function, so we divide by three to get the approximate sigma value. */
sigma_x_ = data_.sizex * size_ / 3.0f;
sigma_y_ = data_.sizey * size_ / 3.0f;
} }
void FastGaussianBlurOperation::init_execution() void FastGaussianBlurOperation::init_execution()