Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

GEGL Motion Noise plugin to create wood and metal textures

Sun Mar 24, 2024 12:16 am

Plugin is officially here
https://github.com/LinuxBeaver/Noise_in ... /releases/

Download binaries and code here *march 27 update
download/file.php?id=74205

We are getting a new GEGL plugin soon called "Brushed Metal". It is not yet in development but here is its graph. I will document part of the process of making this plugin in order to help future GEGL plugin devs and once the plugin is done I will link the Github download.

Preview of Graph
brushed.png
brushed.png (646.85 KiB) Viewed 690 times



Syntax to create effect

Code:
id=x
over aux=[ ref=x

color value=#59cbf3
noise-rgb red=1 green=1 blue=1  gaussian=true linear=true seed=223334
gray
]
crop

motion-blur length=70
unsharp-mask scale=3
opacity value=10
median-blur radius=0


Stay tuned.

Re: GEGL brushed metal background - COMING SOON

Sun Mar 24, 2024 12:21 am

The syntax selected will be made into sliders and color pick dialogs. Below is the planned name of the sliders. Two sliders will use the same gegl:motion-blur

Color
color value=#HTML_COLOR_HERE

Direction of Metal Stain
motion-blur angle=90

Length of metal stain
motion-blur length=70

Detail
unsharp-mask scale=3

Seed
noise-rgb seed=123456789

Re: GEGL brushed metal background - COMING SOON

Sun Mar 24, 2024 12:25 am

There is a problem. The color slider I originally intended is a hidden color and gegl:gray knocks out its effect. But without it the metal stain is less intense. To get a correct color overlay we need something like


id=2 multiply aux=[ ref=2 color value=red ]

color_overlay_metal_stain.png
color_overlay_metal_stain.png (575.29 KiB) Viewed 686 times

Re: GEGL brushed metal background - COMING SOON

Sun Mar 24, 2024 9:40 am

When brown this graph looks like wood. Maybe it should be renamed to "brushed metal and wood"

wood_when_brown.png
wood_when_brown.png (589.43 KiB) Viewed 651 times

Re: GEGL brushed metal background - COMING SOON

Sun Mar 24, 2024 10:33 pm

contrast_ wrote:When brown this graph looks like wood. Maybe it should be renamed to "brushed metal and wood"

"Brushed Texture" should encompass everything going out of that filter (paper, plastic (~3D prints), whatnot), an orientation slider would be mandatory, as well as a "Tileable" option like in "Solid noise" IMO (every rendered texture should have this option IMHO)
screenshot_20240325-122700.jpg
screenshot_20240325-122700.jpg (34.95 KiB) Viewed 615 times

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 9:32 pm

The GEGL nodes in attach have been listed. These are all the GEGL nodes this filter will use. Two of them have color properties attached (default and hidden color.) and Median Blur and Noise RGB have normal properties attached to them.


Code:
static void attach (GeglOperation *operation)
{
  GeglNode *gegl = operation->node;
  GeglColor *hidden_color = gegl_color_new ("#a0a0a0");
  GeglColor *default_color = gegl_color_new ("#e98944");


    GeglNode *input    = gegl_node_get_input_proxy (gegl, "input");
    GeglNode *output   = gegl_node_get_output_proxy (gegl, "output");


    GeglNode *normal    = gegl_node_new_child (gegl,
                                  "operation", "gegl:over",
                                  NULL);
    GeglNode *idref    = gegl_node_new_child (gegl,
                                  "operation", "gegl:nop",
                                  NULL);
    GeglNode *hcolor    = gegl_node_new_child (gegl,
                                  "operation", "gegl:color", "value", hidden_color,
                                  NULL);
     GeglNode *noise   = gegl_node_new_child (gegl,
                                  "operation", "gegl:noise-rgb", "red", 1.0, "green", 1.0, "blue", 1.0, "gaussian", TRUE, "linear", TRUE,
                                  NULL);
     GeglNode *gray    = gegl_node_new_child (gegl,
                                  "operation", "gegl:gray",
                                  NULL);
     GeglNode *crop    = gegl_node_new_child (gegl,
                                  "operation", "gegl:crop",
                                  NULL);
     GeglNode *motion    = gegl_node_new_child (gegl,
                                  "operation", "gegl:motion-blur-linear",
                                  NULL);
     GeglNode *sharpen    = gegl_node_new_child (gegl,
                                  "operation", "gegl:unsharp-mask",
                                  NULL);
     GeglNode *opacity    = gegl_node_new_child (gegl,
                                  "operation", "gegl:opacity",
                                  NULL);
     GeglNode *endfix    = gegl_node_new_child (gegl,
                                  "operation", "gegl:median-blur", "radius", 0, "abyss-policy", 0,
                                  NULL);
     GeglNode *multiply    = gegl_node_new_child (gegl,
                                  "operation", "gegl:multiply",
                                  NULL);
     GeglNode *color    = gegl_node_new_child (gegl,
                                  "operation", "gegl:color", "value", default_color,
                                  NULL);


The UI strings for the filters properties has been filled out. This is the slider name and description area.

Code:
#include "config.h"
#include <glib/gi18n-lib.h>

#ifdef GEGL_PROPERTIES

property_color (value, _("Color"), "#e98944")
    description (_("The color to paint over the brushed metal/wood. The default color makes wood"))

property_double (direction, _("Direction"), 0.0)
    description (_("Direction of brushed metal/wood"))
    value_range (-180, 180)
    ui_meta     ("unit", "degree")
    ui_meta     ("direction", "cw")

property_double (length, _("Length"), 70.0)
    description (_("Length of brushed metal/wood in pixels"))
    value_range (20.0, 150.0)
    ui_range    (20.0, 120.0)
    ui_gamma    (1.5)
    ui_meta     ("unit", "pixel-distance")

property_double (sharpen, _("Sharpen"), 3.0)
    description(_("Sharpen the brushed metal/wood "))
    value_range (0.0, 10.0)
    ui_range    (0.0, 10.0)
    ui_gamma    (3.0)

property_seed    (seed, _("Random seed"), rand)
    description  (_("The random seed for the noise function"))

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 9:34 pm

PixLab wrote:
contrast_ wrote:When brown this graph looks like wood. Maybe it should be renamed to "brushed metal and wood"

"Brushed Texture" should encompass everything going out of that filter (paper, plastic (~3D prints), whatnot), an orientation slider would be mandatory, as well as a "Tileable" option like in "Solid noise" IMO (every rendered texture should have this option IMHO)
screenshot_20240325-122700.jpg


It is impossible to do that because this filter does not use solid noise. It depends mostly on linear motion blur and RGB Noise

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 10:11 pm

Here is the GEGL Graph itself that list the nodes from attach

Code:
/*main graph here. normal and multiply are composers (aka blend modes)*/
  gegl_node_link_many (input, idref, normal, crop, motion, sharpen, opacity, endfix, multiply, output, NULL);
/*the normal blend mode has everything from idref to gray inside it*/
  gegl_node_connect (normal, "aux", gray, "output");
  gegl_node_link_many (idref, hcolor, noise, gray,  NULL);
/*the multiply blend mode has a color node inside of it. obviously to blend the color*/
  gegl_node_connect (multiply, "aux", color, "output");

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 10:15 pm

The GEGL Operation class, title and filter description, and where the filter goes in the menu is here. Since we don't use update_graph, everything will stay in default.

If anyone has been noticing I've been giving my plugins reference hash names based on pop culture references (media, music politics, video games).

Code:
static void
gegl_op_class_init (GeglOpClass *klass)
{
  GeglOperationClass *operation_class;
  operation_class = GEGL_OPERATION_CLASS (klass);
  operation_class->attach = attach;
  gegl_operation_class_set_keys (operation_class,
    "name",        "lb:woodmetal",
    "title",       _("Brushed Metal and Wood"),
    "reference-hash", "dancingthroughthenightonthegroove",
    "description", _("The same background that makes brushed metal also makes wood texture."),
    "gimp:menu-path", "<Image>/Filters/Render/Fun",
    "gimp:menu-label", _("Brushed Metal and Wood Background..."),
    NULL);
}

#endif

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 10:20 pm

Here is something very unique to this filter that only a few filters of mine have.

A mandatory -180 180 and ui_meta ("direction", "cw") are needed to get this circular slider in plugins.

Code:
property_double (direction, _("Direction"), 0.0)
    description (_("Direction of brushed metal/wood"))
    value_range (-180, 180)
    ui_meta     ("unit", "degree")
    ui_meta     ("direction", "cw")


If it is not (-180 180) with the extra ui_meta tag this circular slider will not show up
azimuth_cyclic_slider.png
azimuth_cyclic_slider.png (4.15 KiB) Viewed 578 times

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 10:33 pm

Here is where we define the filter properties that are all based on other filter properties.

Code:
gegl_operation_meta_redirect (operation, "seed", noise, "seed");
gegl_operation_meta_redirect (operation, "sharpen", sharpen, "scale");
gegl_operation_meta_redirect (operation, "length", motion, "length");
gegl_operation_meta_redirect (operation, "direction", motion, "angle"); 
gegl_operation_meta_redirect (operation, "color", color, "value"); 


First is the property name we gave
Second is the defined name in attach
Third is the original filters property name

"newproperty", attachname, "originalproperty")

Usually I keep new and old property names the same to keep it simple but I understand this confuses newbies.

motion is the new property name we defined here
Code:
     GeglNode *motion    = gegl_node_new_child (gegl,
                                  "operation", "gegl:motion-blur-linear",
                                  NULL);


length and direction are both new and old property names

in example gegl:motion-blur angle=30 motion=40 is valid syntax that explains these two lines of code.

Code:
gegl_operation_meta_redirect (operation, "length", motion, "length");
gegl_operation_meta_redirect (operation, "direction", motion, "angle"); 

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 10:37 pm

I just got done compiling the plugin and have no idea if it will work if I did it right or not.

gegls_compile.png
gegls_compile.png (285.25 KiB) Viewed 578 times


*update I had to tweak several sliders and recompile 4 times or so before I got it right.

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 11:27 pm

The filter is done and appears to be working fine. It will be on Github tomorrow or later tonight.

on_soon.png
on_soon.png (603.75 KiB) Viewed 568 times


Anyone is welcome to compile this early. The entire working code is here.

Code:
/* This file is an image processing operation for GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
* 2024 Beaver, Brushed Metal Wood

Recreate graph using this GEGL syntax

id=x
over aux=[ ref=x
color value=#59cbf3
noise-rgb red=1 green=1 blue=1  gaussian=true linear=true seed=223334
gray
]
crop
motion-blur length=70
unsharp-mask scale=5
opacity value=10
median-blur radius=0 abyss-policy=none clip-extent
multiply aux=[ color value=#e98944]
*/

#include "config.h"
#include <glib/gi18n-lib.h>

#ifdef GEGL_PROPERTIES

property_color (color, _("Color"), "#e98944")
    description (_("The color to paint over the brushed metal/wood. The default color makes wood"))

property_double (direction, _("Direction"), 0.0)
    description (_("Direction of brushed metal/wood"))
    value_range (-180, 180)
    ui_meta     ("unit", "degree")
    ui_meta     ("direction", "cw")

property_double (length, _("Length"), 70.0)
    description (_("Length of brushed metal/wood in pixels"))
    value_range (20.0, 120.0)
    ui_range    (20.0, 120.0)
    ui_gamma    (1.5)
    ui_meta     ("unit", "pixel-distance")

property_double (sharpen, _("Sharpen"), 4.5)
    description(_("Sharpen the brushed metal/wood "))
    value_range (2.0, 10.0)
    ui_range    (2.0, 10.0)
    ui_gamma    (3.0)

property_seed    (seed, _("Random seed"), rand)
    description  (_("The random seed for the noise function"))

property_double (desaturate, _("Desaturate (for brushed metal)"), 1.0)
    description(_("Desaturation option to make brushed metal"))
    value_range (0.0, 1.0)
    ui_range (0.0, 1.0)

#else

#define GEGL_OP_META
#define GEGL_OP_NAME     brushed_metal_wood
#define GEGL_OP_C_SOURCE brushed_metal_wood.c

#include "gegl-op.h"

static void attach (GeglOperation *operation)
{
  GeglNode *gegl = operation->node;
  GeglColor *hidden_color = gegl_color_new ("#a0a0a0");
  GeglColor *default_color = gegl_color_new ("#e98944");

    GeglNode *input    = gegl_node_get_input_proxy (gegl, "input");
    GeglNode *output   = gegl_node_get_output_proxy (gegl, "output");

    GeglNode *normal    = gegl_node_new_child (gegl,
                                  "operation", "gegl:over",
                                  NULL);
    GeglNode *idref    = gegl_node_new_child (gegl,
                                  "operation", "gegl:nop",
                                  NULL);
    GeglNode *hcolor    = gegl_node_new_child (gegl,
                                  "operation", "gegl:color", "value", hidden_color,
                                  NULL);
     GeglNode *noise   = gegl_node_new_child (gegl,
                                  "operation", "gegl:noise-rgb", "red", 1.0, "green", 1.0, "blue", 1.0, "gaussian", TRUE, "linear", TRUE,
                                  NULL);
     GeglNode *gray    = gegl_node_new_child (gegl,
                                  "operation", "gegl:gray",
                                  NULL);
     GeglNode *crop    = gegl_node_new_child (gegl,
                                  "operation", "gegl:crop",
                                  NULL);
     GeglNode *motion    = gegl_node_new_child (gegl,
                                  "operation", "gegl:motion-blur-linear",
                                  NULL);
     GeglNode *sharpen    = gegl_node_new_child (gegl,
                                  "operation", "gegl:unsharp-mask",
                                  NULL);
     GeglNode *opacity    = gegl_node_new_child (gegl,
                                  "operation", "gegl:opacity", "value", 10.0,
                                  NULL);
     GeglNode *endfix    = gegl_node_new_child (gegl,
                                  "operation", "gegl:median-blur", "radius", 0, "abyss-policy", 0,
                                  NULL);
     GeglNode *multiply    = gegl_node_new_child (gegl,
                                  "operation", "gegl:multiply",
                                  NULL);
     GeglNode *color    = gegl_node_new_child (gegl,
                                  "operation", "gegl:color", "value", default_color,
                                  NULL);
     GeglNode *desaturate    = gegl_node_new_child (gegl,
                                  "operation", "gegl:saturation",
                                  NULL);
/*main graph here. normal and multiply are composers (aka blend modes)*/
  gegl_node_link_many (input, idref, normal, crop, motion, sharpen, opacity, endfix, multiply, desaturate, output, NULL);
/*the normal blend mode has everything from idref to gray inside it*/
  gegl_node_connect (normal, "aux", gray, "output");
  gegl_node_link_many (idref, hcolor, noise, gray,  NULL);
/*the multiply blend mode has a color node inside of it. obviously to blend the color*/
  gegl_node_connect (multiply, "aux", color, "output");

gegl_operation_meta_redirect (operation, "seed", noise, "seed");
gegl_operation_meta_redirect (operation, "sharpen", sharpen, "scale");
gegl_operation_meta_redirect (operation, "length", motion, "length");
gegl_operation_meta_redirect (operation, "direction", motion, "angle"); 
gegl_operation_meta_redirect (operation, "color", color, "value"); 
gegl_operation_meta_redirect (operation, "desaturate", desaturate, "scale"); 

}

static void
gegl_op_class_init (GeglOpClass *klass)
{
  GeglOperationClass *operation_class;
  operation_class = GEGL_OPERATION_CLASS (klass);
  operation_class->attach = attach;
  gegl_operation_class_set_keys (operation_class,
    "name",        "lb:woodmetal",
    "title",       _("Brushed Metal and Wood"),
    "reference-hash", "dancingthroughthenightonthegroove",
    "description", _("The same background that makes brushed metal also makes wood texture."),
    "gimp:menu-path", "<Image>/Filters/Render/Fun",
    "gimp:menu-label", _("Brushed Metal and Wood Background..."),
    NULL);
}

#endif

Re: GEGL brushed metal background - COMING SOON

Mon Mar 25, 2024 11:41 pm

POST RETRACTED - DOWNLOAD OUTDATED

Re: GEGL wood and brushed metal background plugin

Tue Mar 26, 2024 10:36 pm

Plugin will be getting an update with new features like this

It will have a tab to choose between linear motion blur, circular motion blur and zoom motion blur

Image

Image


Image

Re: GEGL wood and brushed metal background plugin

Tue Mar 26, 2024 10:38 pm

From a technical perspective this filter is a motion blur applied on rgb noise with a multiply blended color overlay.


Maybe I should rename the filter to "Motion blur on noise texture" as that is far more logically accurate then "wood/metal". I could call it "Motion blurred noise".

Re: GEGL wood and brushed metal background plugin

Wed Mar 27, 2024 6:01 am

I installed it, but I get this error message!
I am using Gimp 2.10.36 and 2.99.17

Solved!
I have now added 2.99.18 and it works now. Thank you!

Re: GEGL wood and brushed metal background plugin

Wed Mar 27, 2024 9:31 am

I tested it on Windows 10 Gimp 2.99.18 and it worked.

Jappaloe63 wrote:I installed it, but I get this error message!



Are you using Gimp 2.10.32? As my plugins require GEGL 0.4.46 and up now


If you are using above that try backing up and removing every other plugin but brushed metal and tell me if it works.

Re: GEGL wood and brushed metal background plugin

Wed Mar 27, 2024 1:08 pm

Please try these new Windows and Linux binaries and let me know if they work.

Download Windows and Linux binaries and code here of plugin update
noise_in_motion.zip
(80.11 KiB) Downloaded 24 times

Re: GEGL wood and brushed metal background plugin

Wed Mar 27, 2024 1:12 pm

Jappaloe63 wrote:I installed it, but I get this error message!
I am using Gimp 2.10.36 and 2.99.17


Please try the update. It has no errors unlike the earlier version that did and make sure the update works with all the other plugins of mine you have.
Post a reply