Max4 New Filters
SWiSH Max4 now has built in Filters selectable via the new Filters Panel. One or more filters can be added to a movie clip to alter its appearance in a variety of ways. Filters are most commonly associated with shading effects, however the Convolution and Color Matrix filters allow a variety of custom effects to be authored.
SWiSH Max4 allows you to easily apply filters to any object using the Filters panel. If the Filters panel is not visible, it can be made visible using Window menu item and checking the Filters option or by pressing Ctrl+Shift+F9.
Filter settings can be progressively altered using time line effects, greatly increasing the available creative options.
At first glance, some of the parameters may appear complicated. This blog article attempts to de-mystify filters by explaining each of the parameters in detail.
Many of the filters share common parameters. The common parameters are discussed below:
Angle
Used in: Bevel, Drop Shadow, Gradient Bevel, Gradient Glow
This is the angle (in degrees) of the shadow direction. 0 means right, 90 corresponds to down.
Blur X, Blur Y
Used in: Bevel, Blur, Drop Shadow, Glow, Gradient Bevel, Gradient Glow
This defines the size of the shadow in pixels in the X and Y direction. The flash player is optimized for Blur values that are a power of 2. ie. 2, 4, 8, 16, 32 etc. however, any value up to 255 can be used.
Distance
Used in: Bevel, Drop Shadow, Gradient Bevel, Gradient Glow
This defines the distance in pixels between the shadow and the object.
The Drop Shadow filter performs the same as the Glow filter when the distance is set to 0.
Gradient
Used in: Gradient Bevel, Gradient Glow
This defines the gradient colors that are used by the filter.
Hide Object
Used in: Bevel, Drop Shadow, Glow, Gradient Bevel, Gradient Glow
If set hides the object, showing only the filter effect. This can be useful when applying a skewed drop shadow. To do this, copy the object, skew the copy and apply the drop shadow to the copy. Then hide the copy using this option. Note that this is different to the Knockout parameter.
Highlight Color
Used in: Bevel
Defines the highlight color used by this filter.
Inner shadow
Used in: Bevel, Drop Shadow, Glow, Gradient Bevel, Gradient Glow
Causes the shadow to appear inside of the object.
Knockout
Used in: Bevel, Drop Shadow, Glow
The object and the shadow immediately behind the object is made transparent.
On Top
Used in: Bevel, Gradient Bevel, Gradient Glow
Makes the shadow appear above the object. The default is for the shadow to appear behind the object.
Passes
Used in: Bevel, Blur, Drop Shadow, Glow, Gradient Bevel, Gradient Glow
Sets the quality of the filter calculation. 1 = low quality, 2 = medium, 3 = high quality. Values up to 15 are supported, but there is no real need to go above 3. Increasing quality will increase processor time used to render the object.
When using the filter classes in scripting, this value is often referred to as quality.
Shadow Color
Used in: Bevel, Drop Shadow, Glow
Sets the color of the shadow.
Strength
Used in: Bevel, Drop Shadow, Glow, Gradient Bevel, Gradient Glow
Sets the intensity of the shadow. Note that values > 100% can be used.
When used in scripting, a value of 100% corresponds to 1.
Color Matrix and Convolution Filters
These filters are different from the other filters as they use Matrices to define the way data is processed. Both filters process bitmap versions of the movie clip by accessing the RGBA value of each pixel and then calculating a new value based on the Matrix settings. Although more complex to use, the final results can be very interesting especially when these filters are applied to images.
Color Matrix Filter Parameters
The parameters R’, G’, B’ and A’ are specific to the Color Matrix filter. They represent the new calculated (transform) values for each of the R, G, B and A channels.
Each transform consists of 5 values labeled wr (R weight), wg (G weight), wb (B weight), wa (A weight) and c (Offset) – a constant offset.
These values are applied to a formula:
wr*R + wg*G + wb*B + wa*A + c
which multiplies the weights by the current color values.
The result of the calculation is then clipped to fit within the range 0..255. This transform is then applied on a pixel by pixel basis to the entire object.
There are no other parameters associated with this filter.
Example Transform – Invert Colors
wr | wg | wb | wa | c | |
R’ | -1 | 0 | 0 | 0 | 255 |
G’ | 0 | -1 | 0 | 0 | 255 |
B’ | 0 | 0 | -1 | 0 | 255 |
A’ | 0 | 0 | 0 | 1 | 0 |
The -1 values for each of wr, wg and wb invert the color values. A constant of 255 is added to make the result fall between 0 and 255.
Example Transform – Transpose Colors
wr | wg | wb | wa | c | |
R’ | 0 | 1 | 0 | 0 | 0 |
G’ | 0 | 0 | 1 | 0 | 0 |
B’ | 1 | 0 | 0 | 0 | 0 |
A’ | 0 | 0 | 0 | 1 | 0 |
In this transform green is colored red, blue is colored green and red is colored blue.
Example Transform – Increase Contrast
wr | wg | wb | wa | c | |
R’ | 2 | 0 | 0 | 0 | -128 |
G’ | 0 | 2 | 0 | 0 | -128 |
B’ | 0 | 0 | 2 | 0 | -128 |
A’ | 0 | 0 | 0 | 1 | 0 |
Each color has its intensity multiplied by 2 (0..510). A constant (-128) is then used to reset the black level to be 1/4 along the new color scale. (ie new scale is -128..382. values < 0 are set to 0, values > 255 are set to 255).
Convolution Filter Parameters
This filter works by modifying each pixel in a bit map according to the neighboring pixels and the user specified Convolution Matrix.
If calculating the value for pixel 15, (p15) then the new value is:
p15' = (p8*a0+p9*a1+p10*a2+p14*a3+p15*a4+p16*a5+p20*a6+p21*a7+p22*a8) / Divisor + Bias
This same calculation is applied for each of the RG and B color channels individually. The calculation is also applied to the alpha channel if the Preserve Alpha option is not set.
The original colors for each of the channels is assumed to be in the range 0..255.
In a similar fashion, the value for p22 would be:
p22' = (p15*a0+p16*a1+p17*a2+p21*a3+p22*a4+p23*a5+p27*a6+p28*a7+p29*a8) / Divisor + Bias
Parameters
The image to the left shows the parameters associated with a 3×3 convolution matrix.
The Columns and Rows parameters are used to define the size of the matrix. Once modified the RowN / ColumnM fields will be adjusted to match.
Row1 Column1 corresponds to a0 in the diagram above. In a similar way, Row1 Column3 corresponds to a2 and Row3 Column2 corresponds to a7.
The Divisor and Bias are both additional parameters associated with this filter. (See Below).
Divisor
The matrix calculation is divided by this value. To prevent bleaching or darkening of the image, the result of the calculation should be 1.
ie. for a 3×3 matrix, (a0+a1+a2+…+a8)/Divisor = 1;
Bias
Allows a constant to be applied to the final calculation. This can be used to lighten or darken the result. Generally this value should be an integer between -255 and 255.
Default Color
Defines the color that is used in calculations where the source pixel is off the bitmap.
Clamp
If true, for pixels that are off the source image, the color value is obtained from the edge pixel.
Preserve Alpha
If true alpha values are not re-calculated. If false, Alpha values are calculated according to the convolution matrix.
SMID Extensions
With processors that offer Streaming SMID Extensions, some speed advantages may be obtained if:
- The filter is a 3×3 matrix
- All matrix terms are integers between -127 and 127
- The sum must not exceed +/- 127
- The divisor must be < 256
- If any result is negative, divisor must be > 2
- If all results are positive, divisor must be > 1.1
- Bias must be an integer.
Some example convolution matrices
Blur
Divisor: 16 |
Edge detect
Divisor: 1 | ||||||||||||||||||
Emboss
Divisor: 1 |
Sharpen
Divisor: 4 |
Tags: bevel, blur, color matrix, convolution, drop shadow, filter, Max4
Typo in first sentence – build should be built.
Thanks for pointing that out. Article has been updated.
Jon
So I’ve noticed in order to keep drop shadows on text when exporting, you have to break it into shapes? If i keep it as text, the drop shadow turns the same color as the text. Am I missing something?
Break into shapes should not be required.
Check the color of the filter that you are using in the filters panel.
In the first instance, try red text with the pre-defined filter settings blur8_angle45_distance45 which is available under the Drop Shadow heading.
If the filter does not seem to be working, please submit your .swi file via the forums for discussion.
Jon
I apologize. I have seen the problem that you describe. It only seems to happen when you apply a filter to text that has effects already applied to it.
It appears to be a bug. As a short term fix, convert the text with effect to a movie clip and apply the filter to the movie clip.
Jon