Added a "Sharpen Less" kernel for the Filter Compositor node

Added a new "Sharpen Less" kernel to the filter compositor node. The intent here is to provide a much less aggressive sharpening filter that can't simply be solved by toning down the factor on the existing sharpen filter.

The existing "Sharpen" filter uses a "box" kernel:

```
-1 -1 -1
-1  9 -1
-1 -1 -1
```

The new "Sharpen Less" filter uses a "diamond" kernel:

```
 0 -1  0
-1  5 -1
 0 -1  0
```

The difference between the two is clear to see in the following side-by-side:

{F12847431}

Below shows the difference between the filtering kernels as applied to a B&W render of Suzanne with the UV grid as a texture. The left side of the render using the existing "Sharpen" filter, and the right side showing the new "Sharpen Less" filter. Notice that the left side is more aggressive in accentuating localized contrasts across the image. This can lead to what appears to be aliasing or striations in the resulting image:

{F12847429}

https://developer.blender.org/T95275
https://blender.community/c/rightclickselect/57Kq/?sorting=hot
{F12847428}

Reviewed By: #compositing, jbakker

Differential Revision: https://developer.blender.org/D14019
This commit is contained in:
Colin Basnett 2022-02-09 10:27:35 +01:00 committed by Jeroen Bakker
parent 81da638c44
commit 6f01758b47
3 changed files with 9 additions and 3 deletions

View File

@ -1303,12 +1303,13 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
/* filter types */
#define CMP_FILT_SOFT 0
#define CMP_FILT_SHARP 1
#define CMP_FILT_SHARP_BOX 1
#define CMP_FILT_LAPLACE 2
#define CMP_FILT_SOBEL 3
#define CMP_FILT_PREWITT 4
#define CMP_FILT_KIRSCH 5
#define CMP_FILT_SHADOW 6
#define CMP_FILT_SHARP_DIAMOND 7
/* scale node type, in custom1 */
#define CMP_SCALE_RELATIVE 0

View File

@ -48,7 +48,7 @@ void FilterNode::convert_to_operations(NodeConverter &converter,
2 / 16.0f,
1 / 16.0f);
break;
case CMP_FILT_SHARP:
case CMP_FILT_SHARP_BOX:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
break;
@ -80,6 +80,10 @@ void FilterNode::convert_to_operations(NodeConverter &converter,
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1);
break;
case CMP_FILT_SHARP_DIAMOND:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0);
break;
default:
operation = new ConvolutionFilterOperation();
operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);

View File

@ -465,7 +465,8 @@ static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = {
const EnumPropertyItem rna_enum_node_filter_items[] = {
{0, "SOFTEN", 0, "Soften", ""},
{1, "SHARPEN", 0, "Sharpen", ""},
{1, "SHARPEN", 0, "Box Sharpen", "An aggressive sharpening filter"},
{7, "SHARPEN_DIAMOND", 0, "Diamond Sharpen", "A moderate sharpening filter"},
{2, "LAPLACE", 0, "Laplace", ""},
{3, "SOBEL", 0, "Sobel", ""},
{4, "PREWITT", 0, "Prewitt", ""},