diff --git a/addons/material_maker/nodes/gaussian_blur_hq.mmg b/addons/material_maker/nodes/gaussian_blur_hq.mmg new file mode 100644 index 000000000..f82b1ca6e --- /dev/null +++ b/addons/material_maker/nodes/gaussian_blur_hq.mmg @@ -0,0 +1,396 @@ +{ + "connections": [ + { + "from": "switch", + "from_port": 0, + "to": "switch_2", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "switch", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer_4", + "to_port": 0 + }, + { + "from": "switch_2", + "from_port": 0, + "to": "buffer_5", + "to_port": 0 + }, + { + "from": "buffer_5", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "switch", + "from_port": 0, + "to": "buffer_3", + "to_port": 0 + }, + { + "from": "buffer_4", + "from_port": 0, + "to": "gaussian_blur_x_hq", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "gaussian_blur_x_hq", + "to_port": 1 + }, + { + "from": "gaussian_blur_x_hq", + "from_port": 0, + "to": "switch", + "to_port": 0 + }, + { + "from": "buffer_3", + "from_port": 0, + "to": "gaussian_blur_y_hq", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "gaussian_blur_y_hq", + "to_port": 1 + }, + { + "from": "gaussian_blur_y_hq", + "from_port": 0, + "to": "switch_2", + "to_port": 0 + } + ], + "label": "Gaussian Blur HQ", + "longdesc": "Applys a gaussian blur on its input", + "name": "gaussian_blur_hq", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "switch", + "node_position": { + "x": -529.452392578125, + "y": -15.1666555404663 + }, + "parameters": { + "choices": 2.0, + "outputs": 1.0, + "source": 0.0 + }, + "seed": 20224.0, + "type": "switch" + }, + { + "name": "switch_2", + "node_position": { + "x": -226.452392578125, + "y": 9.33334445953369 + }, + "parameters": { + "choices": 2.0, + "outputs": 1.0, + "source": 0.0 + }, + "seed": -31061.0, + "type": "switch" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -540.0, + "y": -680.0 + }, + "parameters": { + "param0": 9.0, + "param1": 0.2, + "param2": 0.0, + "param3": false, + "param4": 100.0 + }, + "seed": 10501.0, + "type": "remote", + "widgets": [ + { + "label": "Grid size:", + "linked_widgets": [ + { + "node": "buffer_4", + "widget": "size" + }, + { + "node": "gaussian_blur_x_hq", + "widget": "size" + }, + { + "node": "gaussian_blur_y_hq", + "widget": "size" + } + ], + "longdesc": "The resolution of the input image", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Sigma:", + "linked_widgets": [ + { + "node": "gaussian_blur_x_hq", + "widget": "sigma" + }, + { + "node": "gaussian_blur_y_hq", + "widget": "sigma" + } + ], + "longdesc": "The strength of the blur filter", + "name": "param1", + "shortdesc": "Sigma", + "type": "linked_control" + }, + { + "configurations": { + "Both": [ + { + "node": "switch", + "value": 0.0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 0.0, + "widget": "source" + } + ], + "X": [ + { + "node": "switch", + "value": 0.0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 1.0, + "widget": "source" + } + ], + "Y": [ + { + "node": "switch", + "value": 1.0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 0.0, + "widget": "source" + } + ] + }, + "label": "Direction:", + "linked_widgets": [ + { + "node": "switch", + "widget": "source" + }, + { + "node": "switch_2", + "widget": "source" + } + ], + "longdesc": "Apply the blur filter horizontally, vertically or in both directions", + "name": "param2", + "shortdesc": "Direction", + "type": "config_control" + }, + { + "label": "Quality [%]", + "linked_widgets": [ + { + "node": "gaussian_blur_x_hq", + "widget": "quality" + }, + { + "node": "gaussian_blur_y_hq", + "widget": "quality" + } + ], + "name": "param4", + "type": "linked_control" + }, + { + "label": "32 Bits", + "linked_widgets": [ + { + "node": "buffer_4", + "widget": "f32" + }, + { + "node": "buffer_5", + "widget": "f32" + }, + { + "node": "buffer_3", + "widget": "f32" + } + ], + "longdesc": "Use 32-bit buffers when storing input/outputs. Reduces banding artifacts but could result in higher video memory usage.", + "name": "param3", + "shortdesc": "32 Bits", + "type": "linked_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -895.666625976562, + "y": -194.392852783203 + }, + "parameters": {}, + "ports": [ + { + "group_size": 0.0, + "longdesc": "The input image", + "name": "input", + "shortdesc": "Input", + "type": "rgba" + }, + { + "group_size": 0.0, + "longdesc": "A map that controls the strength of the blur filter", + "name": "amount", + "shortdesc": "Strength map", + "type": "f" + } + ], + "seed": 52641.0, + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 193.547607421875, + "y": -135.392852783203 + }, + "parameters": {}, + "ports": [ + { + "group_size": 0.0, + "longdesc": "Shows the generated blurred image", + "name": "port0", + "shortdesc": "Output", + "type": "rgba" + } + ], + "seed": 77778.0, + "seed_locked": true, + "type": "ios" + }, + { + "name": "buffer_4", + "node_position": { + "x": -400.0, + "y": -440.0 + }, + "parameters": { + "f32": false, + "filter": false, + "mipmap": false, + "size": 9.0 + }, + "seed_int": 0, + "type": "buffer", + "version": 2 + }, + { + "name": "buffer_5", + "node_position": { + "x": -60.0, + "y": 0.0 + }, + "parameters": { + "f32": false, + "filter": false, + "mipmap": false, + "size": 11.0 + }, + "seed_int": 0, + "type": "buffer", + "version": 2 + }, + { + "name": "buffer_3", + "node_position": { + "x": -620.0, + "y": 120.0 + }, + "parameters": { + "f32": false, + "filter": false, + "mipmap": false, + "size": 11.0 + }, + "seed_int": 0, + "type": "buffer", + "version": 2 + }, + { + "name": "gaussian_blur_x_hq", + "node_position": { + "x": -420.04296875, + "y": -171.733642578125 + }, + "parameters": { + "quality": 100.0, + "sigma": 0.2, + "size": 9.0 + }, + "seed_int": 0, + "type": "gaussian_blur_x_hq" + }, + { + "name": "gaussian_blur_y_hq", + "node_position": { + "x": -372.440856933594, + "y": 137.266357421875 + }, + "parameters": { + "quality": 100.0, + "sigma": 0.2, + "size": 9.0 + }, + "seed_int": 0, + "type": "gaussian_blur_y_hq" + } + ], + "parameters": { + "param0": 9.0, + "param1": 0.2, + "param2": 0.0, + "param3": false, + "param4": 100.0 + }, + "scroll_offset": { + "x": -674.78515625, + "y": -797.727294921875 + }, + "seed_int": 0, + "shortdesc": "Gaussian Blur HQ", + "type": "graph" +} diff --git a/addons/material_maker/nodes/gaussian_blur_x_hq.mmg b/addons/material_maker/nodes/gaussian_blur_x_hq.mmg new file mode 100644 index 000000000..e3be72cf0 --- /dev/null +++ b/addons/material_maker/nodes/gaussian_blur_x_hq.mmg @@ -0,0 +1,96 @@ +{ + "name": "gaussian_blur_x_hq", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "quality": 100.0, + "sigma": 0.2, + "size": 11.0 + }, + "seed": 4629.0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "amount", + "type": "f" + } + ], + "instance": [ + "vec4 $(name)_fct(vec2 uv) {", + "\tfloat e = 1.0/$size;", + "\t//range based on 68–95–99.7 rule", + "\tfloat scaled_sigma = $sigma /10.0;", + "\tfloat sampling_range = scaled_sigma*3.0;", + "\tvec4 rv = vec4(0.0);", + "\tfloat sum = 0.0;", + "\tfloat sigma = max(0.000015, scaled_sigma*$amount(uv));", + "\tfloat mapped_quality = 1.0 + ($quality - 1.0) * ($size - 1.0) / (100.0 - 1.0);", + "\t", + "\tfloat step_size = max(e,1.0/mapped_quality);", + "\t//maxium number of loop iterations = 1024", + "\tstep_size = max(sampling_range*2.0/1024.0,step_size);", + "\tstep_size -= mod(step_size, e);", + "\tfloat coef_diff = 6.28318530718*sigma*sigma;", + "\tfor (float i = -sampling_range; i <= sampling_range; i += step_size) {", + "\t\tfloat i_sigma = i/sigma;", + "\t\tfloat coef = exp(-0.5*i_sigma*i_sigma)/coef_diff;", + "\t\trv += $in(uv+vec2(i, 0.0))*coef;", + "\t\tsum += coef;", + "\t}", + "\treturn rv/sum;", + "}" + ], + "name": "gaussian_blur_x_hq", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 2.0, + "min": 0.0, + "name": "sigma", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 50.0, + "label": "Quality", + "max": 100.0, + "min": 1.0, + "name": "quality", + "step": 1.0, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/gaussian_blur_y_hq.mmg b/addons/material_maker/nodes/gaussian_blur_y_hq.mmg new file mode 100644 index 000000000..fd679ed9a --- /dev/null +++ b/addons/material_maker/nodes/gaussian_blur_y_hq.mmg @@ -0,0 +1,97 @@ +{ + "name": "gaussian_blur_y_hq", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "quality": 100.0, + "sigma": 0.2, + "size": 11.0 + }, + "seed": 12279.0, + "seed_locked": true, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "amount", + "type": "f" + } + ], + "instance": [ + "vec4 $(name)_fct(vec2 uv) {", + "\tfloat e = 1.0/$size;", + "\tfloat scaled_sigma = $sigma/10.0;", + "\t//range based on 68–95–99.7 rule", + "\tfloat sampling_range = scaled_sigma*3.0;", + "\tvec4 rv = vec4(0.0);", + "\tfloat sum = 0.0;", + "\tfloat sigma = max(0.000015, scaled_sigma*$amount(uv));", + "\tfloat mapped_quality = 1.0 + ($quality - 1.0) * ($size - 1.0) / (100.0 - 1.0);", + "\t", + "\tfloat step_size = max(e,1.0/mapped_quality);", + "\t//maxium number of loop iterations = 1024", + "\tstep_size = max(sampling_range*2.0/1024.0,step_size);", + "\tstep_size -= mod(step_size, e);", + "\tfloat coef_diff = 6.28318530718*sigma*sigma;", + "\tfor (float i = -sampling_range; i <= sampling_range; i += step_size) {", + "\t\tfloat i_sigma = i/sigma;", + "\t\tfloat coef = exp(-0.5*i_sigma*i_sigma)/coef_diff;", + "\t\trv += $in(uv+vec2(0.0, i))*coef;", + "\t\tsum += coef;", + "\t}", + "\treturn rv/sum;", + "}" + ], + "name": "gaussian_blur_y_hq", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 2.0, + "min": 0.0, + "name": "sigma", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Quality", + "max": 100.0, + "min": 1.0, + "name": "quality", + "step": 1.0, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/material_maker/doc/images/node_filter_blur_hq.png b/material_maker/doc/images/node_filter_blur_hq.png new file mode 100644 index 000000000..3b4480ec6 Binary files /dev/null and b/material_maker/doc/images/node_filter_blur_hq.png differ diff --git a/material_maker/doc/node_filter_blur_hq.rst b/material_maker/doc/node_filter_blur_hq.rst new file mode 100644 index 000000000..dc7443978 --- /dev/null +++ b/material_maker/doc/node_filter_blur_hq.rst @@ -0,0 +1,46 @@ +Blur HQ node +~~~~~~~~~~~~ + +The **Blur HQ** node applies a high-quality Gaussian blur algorithm to its input. + +.. image:: images/node_filter_blur_hq.png + :align: center + +Inputs +++++++ + +The **Blur HQ** node accepts an RGBA input to be blurred and an optional blur mask +that defines the intensity of the blur effect. + +Outputs ++++++++ + +The **Blur HQ** node outputs the result of the blur operation. + +Parameters +++++++++++ + +The **Blur HQ** node has five parameters: + +* The *Grid Size* defines the size of the output image. + +* The *Sigma* parameter defines how smooth the output will be. + +* The *Direction* specifies if the blur algorithm is applied horizontally, vertically or both. + +* The *Quality* specifies the quality the blur algorithm. + +* whether *32 Bits* buffer(s) are used to store input/outputs. + Reduces banding artifacts but could result in higher video + memory usage. + +Notes ++++++ + +This node outputs an image that has a fixed size. + +Example images +++++++++++++++ + +.. image:: images/node_blur_samples.png + :align: center diff --git a/material_maker/library/base.json b/material_maker/library/base.json index 6dd7dd015..73a561c4e 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -8261,6 +8261,19 @@ }, "tree_item": "3D/Texture/Warp", "type": "tex3d_warp" + }, + { + "display_name": "Blur HQ", + "icon_data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAACJFJREFUeJzVW2uTosoSTKVBHqKjjrH///fNAxUBEYT7YSP7FG2jeI/MeCqC0F3HR2VlZ1VXNRMALR60yWRy83Fsa9v25uMjph59g3R2Op1iMplcXebfPsNMJ5umQdu2nUu+PtQeAoAOTqdTTKdTOI6jL/7bBsSzrG1bNE2jr8vl0rn4+iMgPMwAOuq6LlzXhed58DwPrut2wHg2CIzy5XJBXdeoqgpVVeF8PuvndV0DwEMgDAaAkXccB57nwfd9+L6PIAgQBAF834fneVBKaRD4vmeYdP58PuN0OuF0OqEoChRFoUGvquqh5fAQAIy87/uIoghxHCOOY8znc4RhiCAI4HmeZgLf9wxr21ZH/nQ6IcsyHI9HpGmql57Ug6EsGASAGf0wDLFYLLBarbBarbBcLrFYLBCGIWazGVzXffoy4JovyxJ5niNNU+x2O3iep9kmNaJtWw3KLbsLAJ2g80EQYD6f4+3tDZvNBtvtFpvNBsvlEvP5XC+FMQCo6xplWSLLMux2O/i+D6WUfp1iKEEAbi+FQQyYTqdQSl1Ff7vd4s+fP9hut1itVojjGEEQaEF8tgjWdY3T6YTj8YgwDOF5HiaTiQZHiiGB+FcMkNR3XVdHf7lcYr1edwBYr9eYz+cagGcyQGaAsixxPB4xm83gOA6apkFVVSjLEmVZ6qxQ1/UgFgwCwHVdzGYzhGGIOI41/TebDd7f3/H+/o7VaqWXgFJKA/AsIwDn8xm+78NxHLRtq0WRGeF0O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G9/uD/AICPNofH3g1KIMxLvj7U/gdIfClweecvvgAAAABJRU5ErkJggg==", + "name": "gaussian_blur_hq", + "parameters": { + "param0": 9.0, + "param1": 0.2, + "param2": 0.0, + "param3": false + }, + "tree_item": "Filter/Blur/HQ", + "type": "gaussian_blur_hq" } ], "name": "Base library"