0

I'm trying to create a bevel effect on some text as if the sides slope to a sharp point.

two bevels

I can get a simple, fixed-width bevel with a basic light+blur setup, sort of like the square on the right. How can I get an effect like on the left? (Drawing stuff by hand is not very practical, as I need this to work not just on "text", but on a font where the glyphs have jagged outlines.)

I tried duplicating the text and applying an inset, which sort of works but causes a slight dark outline between each iteration.

(One way of looking at this is that I want each interior point shaded according to the slope of the nearest point on the shape's outline.)

I'm using (and would prefer) Inkscape, but I can live with solutions for how to do this in GIMP.

1 Answer 1

1

I got this sort-of working with the following procedure. This will probably need to be tweaked in order to be generally used.

First, let's consider how the "not what we want" bevel is implemented:

  • Gaussian Blur
  • Lighting (Diffuse and/or Specular)
  • Composite (Arithmetic, K2=0.5, K3=0.5)
  • Composite (Arithmetic, K1=1.0, K3=1.0)

I'm not going to fill in all the details; this is the setup attained via Filters > Bevels > {Diffuse,Specular} Light, except that the first Composite has been tweaked to also add shadow.

The above looks like this: example of "bad" bevel

The problem is that the gradient which generates the bevel is centered on the edge of the shape and stops at roughly the blur radius. We need it to continue until it meets at a point (or, more accurately, a ridge). We can see that narrow places already have the desired effect, so one might think that simply increasing the blur radius would work... and it does, sort of, but at the cost of losing fine details. We don't want that, and we can do better!

I didn't find a generalized way to accomplish this. However, for sufficiently thin objects, it can be faked by adding a Morphology (Erode) filter after the initial Gaussian Blur and using Composite (Arithmetic, K2=0.5, K3=0.5) to "extend" the gradient further into the shape. In my case, I had to repeat this several times. Note that the input for each Morphology is the previous Morphology (or the Gaussian Blur for the first Morphology), while the inputs for each Composite is the previous composite (in the first case, the Gaussian Blur) and the next Morphology. In theory, I suppose this can be repeated indefinitely, perhaps with some adjustments to the Composite weights per step.

The stack looks something like this:

  • blur1
  • erode1
  • erode2
  • erode3
  • ...
  • composite1 (blur1, erode1)
  • composite2 (composite1, erode2)
  • composite3 (composite2, erode3)
  • ...

Depending how much initial blur you're willing to tolerate (remember, more blur means less detail), the Erode distance can be somewhere between half the blur radius and twice the blur radius. (I had good results using 3.0 for the blur radius, 2.0 for the first Erode distance, and 4.0 for the subsequent Erode distances. Mind, this is for a font with a top-to-baseline height of about 300, i.e. the blur radius is almost exactly 1%, or roughly equal to the "feature size" of my shapes.)

I found (as also noted in the Question) I was getting a bit of a black border. I mitigated by adding another Gaussian Blur at the end of the stack with a very small (0.5) radius. It isn't perfect, but fortunately my final application has the text on a black background, so it wasn't a major issue. As this seems to be the result of computation artifacts, another likely mitigation would be to export at a very high resolution and downsample.

The end result looks like this: example of desired bevel

(There are some computation artifacts at the bottom of the 'F' in this example, but they don't show up at all zoom levels.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.