GIMP 3 RC2/ Python example for using gegl:bumpmap

Can someone please provide an example of how to use gegl:bumpmap in a python script with the new API?

This is what I have so far:

img = Gimp.get_images()[0]
rand = img.get_layers()[1]
bump_aux = img.get_layers()[2]


bumpmap_filter = Gimp.DrawableFilter.new(rand, "gegl:bump-map", "")
bumpmap_filter_config = bumpmap_filter.get_config()
bumpmap_filter_config.set_property("type", "spherical")
bumpmap_filter_config.set_property("azimuth", 135.0)
bumpmap_filter_config.set_property("elevation", 45.0)
bumpmap_filter_config.set_property("depth", 10)
bumpmap_filter_config.set_property("offset-x", 0)
bumpmap_filter_config.set_property("offset-y", 0)
bumpmap_filter_config.set_property("waterlevel", 0.0)
bumpmap_filter_config.set_property("ambient", 0.0)

Gimp.DrawableFilter.set_aux_input(bumpmap_filter, bump_aux, rand)

It complains about the bump_aux and I have no idea what to put there.

Also what other types besides “spherical” are possible?

Yes, this is not how gimp_drawable_filter_set_aux_input() is used. Cf. the docs. The second parameter is a pad name (here this is “aux” which is the usual auxiliary pad name, then we have “aux2”, etc. when there are more aux inputs) and the third parameter is the drawable to be used for auxiliary input.

So bottom line:

bumpmap_filter.set_aux_input('aux', bump_aux)

Unfortunately, right now, I’m not sure if we have any docs listing the various values for enum types in GEGL operations. We should improve GEGL ops docs generation, and even I think it’d make sense eventually to have some ops browser for developers in GIMP (same as you can browse API).

So anyway, for the time being, directly referring to the operation’s source code is the way to go. A simple grep -rI gegl:bump-map operations/ in GEGL source code would find the correct file. I did this for you in this specific case, and here is the file and in particular the specific lines referring to this enum type: operations/common-gpl3+/bump-map.c · master · GNOME / gegl · GitLab

So as we see, you also have “linear” and “sinusoidal” (note: there was a typo as it was “sinusodial” until just 5 minutes ago — because I just fixed it —, so if you use a release build, use “sinusodial”, but from next release, or if you use the dev branch of GEGL, it’s now proper “sinusoidal”).

1 Like

Thanks a lot. Now it works.

Yes, that would be great.

Happy new year to you and the team!