VinnieF
![]()
Posts: 5 |
I'm working on implementing Photoshop Layer Styles in my MIT licensed project:
https://github.com/vinniefalco/LayerEf...d/graphics After a lot of study and searching I figured out that the distance transform plays a key role in implementing almost all the styles. You can see clear evidence of the distance transform by turning on the "Stroke" layer style, setting the fill type to Gradient, and choosing "Shape Burst" for the style. If you set the Outer Glow style to the "Precise" technique it also shows direct evidence of a canonical distance transform. But what is the algorithm used for the "Soft" technique? It does not look like a distance transform. At least, not directly. There seems to be some sort of blur. But its not a blur because I try blurring the mask using similar settings, and doing a difference calculation on the outer glow versus my blurred mask and there are some small pixel differences at various radii. Can someone please point me in a direction for implementing the "Soft" technique of Photoshop's Outer Glow filter? Thanks ![]() Github: https://github.com/vinniefalco |
|||
Posted: August 13, 2012 9:41 am | ||||
Ghislaine
![]() |
||||
Posted: August 13, 2012 11:23 am | ||||
CorvusCroax
![]() |
Hi Vinnie,
Welcome to FF! Having a simple outerglow and inner glow FF node exactly like photoshop's is something some of us have been agitating for for some time. (especially in 'precise' mode. The stock answer is that FF's architecture is sample-based, not pixel based. I'd guess the closest you can get is to: Use percentile to 'offset' the shape. Then use gaussian blur. The 'offset' and the blur distance are then plugged into the same control: "Distance" |
|||
Posted: August 13, 2012 11:51 am | ||||
VinnieF
![]()
Posts: 5 |
Hi, and thanks for the warm welcome.
To be clear, I'm looking to understand the algorithm that Photoshop uses, not to come up with some approximation. I think that before attempting an approximation using available tools (if they are limited, as you said that Filter Forge is sample based), it is beneficial to understand exactly what is being approximated. So what exactly is Photoshop doing for "Softer?" I can confirm with 100% certainty that for "Precise" it is a simple anti-aliased distance transform, I can reproduce it in my demo application. I can also confirm that the "Softer" and "Precise" distance transforms are the basis of almost all the Layer Style effects. Drop shadow is Outer Glow in "Softer" mode (with an offset and optional knockout). Stroke with Gradient/Shape Burst is a "Precise" distance transform. Inner Glow is your choice "Softer" or "Precise" distance transform. Inner Shadow is the "Softer" distance transform. I did all my tests using difference calculations on channels and they are exactly the same. My intuition tells me that the Bevel and Emboss style uses the "Softer" distance transform for calculating the height map in "Smooth" mode, and the "Precise" distance transform for the two "Chisel" options. Summary: The distance transform is a useful operation for producing a variety of layer effects. Photoshop seems to use two forms of the distance transform: "Precise", which creates the traditional definition of the distance transform, and "Smooth" which produces a similar effect but is not the same. A deeper understanding of the "Smooth" distance transform would be useful in reproducing similar effects. Github: https://github.com/vinniefalco |
|||
Posted: August 13, 2012 12:00 pm | ||||
Sphinx.
![]() |
Hi Vinnie,
Nice work you started there ![]()
(Mid page: http://help.adobe.com/en_US/photoshop...89ba.html) Try blurring the distance transformed mask, or blur the mask before distance transform for the "mixed modes". The blurring technique used is probably a 3 pass box blur approx. of a gaussian blur |
|||
Posted: August 13, 2012 1:02 pm | ||||
VinnieF
![]()
Posts: 5 |
Thanks! That quote fr om the manual is quite informative. You suggested a 3 pass box blur. Repeated application of a box blur results in a gaussian kernel (central lim it theorem). I did a quick test of box blur versus drop shadow here's the result.
Can box blur be made exceptionally fast? I would think so since the weights are equal and the kernel is separable. You suggest a 3 pass box blur. How do I handle the case of size = 1? Would that be just one box blur? What about size 2? two box blurs? Size 6? Three 2-pixel box blurs? Give the size parameter, range [0,250] what formula do you suggest for the number of passes and the size of each pass? ![]() Github: https://github.com/vinniefalco |
|||
Posted: August 13, 2012 1:52 pm | ||||
VinnieF
![]()
Posts: 5 |
Here's a comparison of Box Blur and Drop Shadow for size = 1. As you can see, there are some slight differences in the values. Drop Shadow at size = 1 is definitely not using a Box Blur with radius = 1 on the mask.
![]() Github: https://github.com/vinniefalco |
|||
Posted: August 13, 2012 2:01 pm | ||||
Sphinx.
![]() |
I don't think you have a 1:1 relation btwn radius and size, that would not make sense. Size is probably half of radius and then black point compensated, i.e. move the black point to 50% (or 127).
Try creating a setup where you can inspect the difference gradually as you tweak the blur radius. |
|||
Posted: August 14, 2012 12:57 am | ||||
VinnieF
![]()
Posts: 5 |
Anyone heard of the "Gaussian Distance Transform" ??
Github: https://github.com/vinniefalco |
|||
Posted: August 20, 2012 4:37 pm |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,712 Registered Users
+19 new in 30 days!
153,533 Posts
+31 new in 30 days!
15,348 Topics
+73 new in year!
33 unregistered users.