Author Topic: Bump filter does not reliably export to PNG  (Read 939 times)

February 06, 2019, 08:34:31 PM
Read 939 times

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
I jumped up and down with glee when I discovered filters. I spent at least a couple of hours creating an image using a combination of a bevel with overlay glow and drop shadows, inside and out. Then I applied a paper bump filter to the background shape. The bevel components exported flawlessly into a png file, but the paper bump texture is lost, leaving the image with a plain flat background.

I tried a new file with a simple rectangle fill and applied the same filter. That exported just fine. But when I went back into my original file, removed the filter and tried again, it failed again. I'm using Inkscape 0.92 on Windows 10. Any suggestions?
  • .092
  • Windows 10 Home

February 07, 2019, 07:09:37 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Possibly you didn't use the right option when you exported the PNG, but it's hard to say.  I would expect the export to pick up the background.

Can you share the SVG file, so we can test it?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 07, 2019, 11:43:22 AM
Reply #2

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
Possibly you didn't use the right option when you exported the PNG, but it's hard to say.  I would expect the export to pick up the background.

Can you share the SVG file, so we can test it?

SVG file attached. I don't think export options were the problem. But hold on. I've been routinely exporting pages for a long series of files I'm creating so I can control placement for printing. But your comment gave me pause. Maybe, just maybe, the ones that exported accurately were selections rather than pages. I tried exporting as a selection. Bingo! That solved the problem. I'm also attaching the PNG version.

Thanks for your help.
  • .092
  • Windows 10 Home

February 07, 2019, 04:05:36 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hhmm, yes, I'm getting the same results that you report.  I'm thinking this must be a bug.  I've never seen Export PNG not export exactly what's on the page.

And I don't know why it's not picking up the filter.  It really should be.  Let me test an older version of Inkscape....

Hhm, I've tested with both 0.91 and 0.48, with the same results.  There must be some reason for this, although I'm not sure what it is.

Tell me....well no, I'll just test it myself.  I'm wondering if a white rectangle (the size of the page) or even changing the background to opaque, might make it capture the filter.  Let's see....   Arrggh!!  Neither of those worked.

I don't know why it doesn't pick up the filter, but I really expected it should.  I'm going to have to ask the developers, because I'm just too curious.  Can I show them your file?  Or would you rather I make up a generic test file?

Oh, interesting.  I removed the filter you were using, and tried a different one, and it picks up that filter.  I used Materials > 3D Mother of Pearl.  Now I've tried 5 different filters, and they all are working.

Hopefully our filters expert will chime in shortly.  He'll be able to say if there is something about this one filter which might be causing the problem.

Well hang in there.  We'll get to the bottom of this eventually, I think.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 07, 2019, 06:35:11 PM
Reply #4

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
You'd better stick with my file for consistency as well as making others. Yes, you may show it to the team. Did you pick up on my message that exporting only the selection rather than the page did keep the texture? I attached a copy of that PNG. I was able to get the result I need for now that way. Best wshes to all on debugging. If I knew enough, I'd be in there plugging away with y'all.

  • .092
  • Windows 10 Home

February 07, 2019, 07:08:51 PM
Reply #5

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Did you pick up on my message that exporting only the selection rather than the page did keep the texture?

Yes, I got the exact same result.  If Lazur doesn't know what's causing it, I'll be sure an give developers all the details.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 08, 2019, 01:06:17 AM
Reply #6

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Hi.

The filter chain in question -paper bump- includes a convolve matrix filter primitive.
That is most known in raster editor to generate neon edges and such filters. It pulls in the rendered data pixel by pixel -adjusted to the actual screen resolution, zoom level, whatever you call it- and applies a 5*5 "kernel" -which is like multiplying every pixel (r, g, b, a) with a given matrix. That means it takes effect in a 2 px range around every pixel at a given time.
Resulting in an "unscalable" effect. It is independent from the number of output pixels, it will always work on that 2 px neighbouring pixels.

Conclusion: it is not advised to use the convolve matrix filter primitive because you will only see the same appearance when viewed at the exact same size. Exporting at a larger resolution thus making the look smoother.
It is expected and it is how it's rendered in browsers too.


On the other side the built-in filters are outdated in general. Since their implementation the component transfer filter primitive made it's way into the available filter primitives inkscape can use (probably could render it before but they weren't available in the filter editor).
Which could be used more effectively in the filter chain.
Those outdated filters use the colormatrix filter primitive alot instead and weird ways for arithmetic compositing which is not so self-explanatory for the naked eye.


Here is a short screen capture on how to make a simple bump texture from scratch you may find interesting:

February 08, 2019, 09:56:24 AM
Reply #7

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
Thank you Lazur for that detailed reply. I can follow most of it, especially the part about scaling, but I set the page and resolution before I started the graphic, and when I exported the selection rather than the page, It exported at the precise pixel dimensions I'd specified (not quite the entire page size, but the size I wanted for the image). So it was not scaling to fit the page. Obviously something went astray when the page size definitions were added to the figure. The other thing I did not do with the page export was select the image. For other images I've not needed to do that for a successful export.

The video is awesome. Much of it is over my head in terms of understanding the various concepts, but I get the general drift and it looks like fun to experiment with. Can you link to a resource that explains the various elements involved, like azimuth and few others?

Thanks a bunch!
  • .092
  • Windows 10 Home

February 08, 2019, 05:18:00 PM
Reply #8

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
The only resource I know of is the svg specs. It doesn't give a practical hint on how to rig a filter chain.
For a long time I had a disapproval towards using filters in vectorgraphics and still not convinced of its practical usability at all.
Started to look at existing filters from the dropdown list. What that mess in the filter editor can be rendered and what changing a parametre would affect the result.
It didn't really work.

Then played a bit with the trial version of filterforge.
That is a decent node editor and has way more primitives the svg specs can offer.
Ran out of trial time gave another try to the filter editor in inkscape.

The biggest issue was which nodes to connect and how.


Trying to explain the filter chain above in the video.
There are two flood fills to start. They fill up the filtered area with a given colour. With compositing you can fill up any given area with a flood colour. It works as boolean operation. Composite-in equals to intersecting. It substitutes the rendered colour while preserving the alpha values of the pixels =everything remains the same opaque, but filled with the input.

The turbulence primitive is another input primitive. It generates a random noise that is not supposed to repeat.
Its settings can modify its scale and detail level but not the overall alpha value or the structure of the randomness.

The component transfer can modify a channel of the rendered image so used it to make the alpha values of the turbulence steeper.

That's because there is the diffuse filter primitive, which is supposed to use the alpha channel of the image as a bumpmap and sort-of generate a 3D geometry to it where full opacity is the top and full transparency is the bottom of the 3D object. The light azimuth sets the direction in which the rays hit the surface. 90° is at zenith -light coming directly perpendicularly to the surface. It doesn't produce much of a 3D feel then.
Setting that value too low may result in low lighting values.
This primitive outputs a fully opaque fill so to colourize it, converted the luminance to alpha and used compositing eith the flood fills.
This could also be done some other ways too but this gives the most exact or self-explanatory colour mapping.
-Which by the way is like the very start in filterforge...-
Used the other turbulence for distorting the result a bit, for more "randomness".

Xav covered filters in his series in the full circle magazine.
Made  a compilation of the related tutorials here.

Besides I was about to make a cookbook of using filters in inkscape but got really lost somewhere.

February 09, 2019, 07:20:31 AM
Reply #9

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
The value of filters in Vectorland? Same, IMO, as in Rasterland -- to give us more flexibility of expression.

Although I only stumbled across the Filters function in Inkscape a couple of days ago and it really lit my fire. Your description of filter engines capabilities have piqued my interest. Do I want to follow the call of that siren or hope other geeks (like you), who remember what concepts like Boolean and primitive input mean and how they work, continue to develop that thread? I have an uneducated hunch that if those filters are refined, they could exceed what's I've found for GIMP. I’ll dip my toes in the water and see how it feels. A quick glance at the budding cookbook you mentioned above looks like it may lead me in a good direction.

:ur:
  • .092
  • Windows 10 Home

February 09, 2019, 07:22:12 PM
Reply #10

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
So, getting back to why the Paper Bump filter won't export to a PNG.  Is it because of convolve matrix?  Because I was exporting to 96 dpi.  Not changing the size.

Should we file a bug report to request removing the convolve matrix primitive from Inkscape?  Or maybe to request putting a notification (in the primitive description) that it won't export to PNG?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 10, 2019, 05:59:27 AM
Reply #11

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
If there is a bug, it's that it is not exporting the entire PAGE to PNG. It did export a grouped selection just fine, and at the same size as it would have had on the designated page size. I've attached the file in both SVG and PNG format.

To double-check whether there might have been some fluke with my original file, I started from scratch with a new file, using the same paper texture filter. As luck would have it, I had just rebooted my system for other reasons, so any artifacts from earlier work should be flushed out.

The image kept its texture when exported as a page. However, if you compare this new file to the original bump map test file (I'm attaching it again), the texture is entirely different. I double-checked both files in Inkscape by opening the filter editor and both show Paper Bump as the active filter. I have not tinkered with that filter at any point, so the settings should be the same. I tried all filters in the Bumps category, and none have the smooth, fine-grained appearance of the green heart in the first file. ??? None look remotely close to the name they bear.

In my case, filters are today's bright shiny object, but it would be nice to be able to predictably use them for future purposes. I'm happy to keep fiddling and testing if I can be of help. I leave it to those with more experience with the Inkscape development team and more knowledge of the inner workings of filters to report official bugs.

For whatever it's worth, when I did fiddle with a couple of other filters while exploring capabilities of the filter editor, I made them finer and denser, not more widely spread. I have no idea how filters are saved, or whether edits on one filter bleed over into another. I'm hopeful that someone will do a tutorial on filters day soon.
  • .092
  • Windows 10 Home

February 10, 2019, 07:34:12 AM
Reply #12

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
The convolve matrix is not a bug itself yet the results may be unexpected.

First, it works on that 2 px range which by definition should render "differently" with every zoom level. Or, more like the exact same.
In nature it'd be similar to a stroke width rendered exactly 5 px wide, regardless zooming. There is an svg function to that as well although for practical use it is usually an unwanted feature.
But not entirely should it be eliminated. In this filter the isolines are kept as "hairlines" which fits the purpose well.

Then there is the problem of transformation matrices. In the preferences by default transformations are set optimized but it seems that filters can inherit transformations preserved. They can be scaled and skewed and there is no visual indication of their scale factor or even better a handle to adjust the transformations.
As the radial gradients are "supposed" to be handled. (Which by the way isn't the best either since you can skew a gradient fill, resulting the two handles not being perpendicular anymore...)

Thirdly, there comes the shallow colour range.
The diffuse primitive uses the alpha channel, which is limited to 256 values. This doesn't give a nice, uninterrupted transition but instead more of a halftone look.


And on top of it, the rendering blows. There is no fast way to try-and retry a filter setting affecting the look. And even harder it is to tweak the settings so a decent resolution wouldn't look messed up.


To sum it up

-Convolve matrix is not an svg problem but they better not be involved within the built-in filters.
-Reworking and preferably ditching the current built-in filters would be the best.
-Ideally filters should be loaded in from a database and easily drag&dropped from one drawing to another.
-There needs to be a decent filter editor with a node based editor and a decent preview option.
-In that editor the possibility to group&stitch subchains from another filter, and labeling etc. would be mandatory.
-There needs to be a gui reference or somekind of indication of transformations.
-Extending the colour range would need reworking of the whole filtering concept and probably would need to take place in the svg specs.

February 10, 2019, 08:37:31 AM
Reply #13

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
None look remotely close to the name they bear.

Hah!  Yes, it seems like not very many really do look much like their names.  Also I've learned that some of them look very different on very small or narrow objects, such as text, than they look on large objects.  Sometimes they look more like their names on certain size or shape of objects.

Interesting.  Yes, I can also confirm that the filter exports properly in a new blank file.  While I'm so curious what's happening in your original file that it won't export, I probably don't have the necessary skills, or time, to figure out what's causing the problem in that file.

But now that I see it exports properly, I'm not concerned about any possible bug.

Thanks for your comments, Lazur.  Very thorough and well done, as always :)
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 10, 2019, 10:42:08 AM
Reply #14

ImaGeek

  • Jr. Member

  • Offline
  • ***

  • 13
While I understand and appreciate the need for control and consistency, given the understanding that filter behavior is virtually random at this point, they are fun to play with. They are great creativity boosters! So you fellows have fun refining them. I'll have fun playing with the existing set and eagerly test new developments if I'm in the loop to do so.
  • .092
  • Windows 10 Home