Source filters, backdrop filters and box shadows
Ordered source filters, backdrop blur and rectangle shadows.
A shape, group or sequence can own one optional filter. Its children form an ordered list of named image operations. The first operation receives the assembled local picture. Each subsequent operation receives the entire preceding result. Operations may repeat, and an empty list returns its input. The filter occupies no drawing slot among the owner's children.
<shape>
<rect anchor-u="0" anchor-v="0" offset-x="16" offset-y="12" width="64" height="40" corner-radius="6"/>
<box-shadow dx="0" dy="5" spread="1" sigma="3" color="#00000060"/>
<fill><paint><image href="./mark.svg"/></paint></fill>
<box-shadow inset="true" dx="1" dy="2" sigma="1" color="#20103060"/>
<filter>
<inner-shadow dx="2" dy="2" sigma="1" color="#10305080"/>
<blur sigma="1"/>
<drop-shadow dx="6" dy="0" sigma="2" color="#10305080"/>
</filter>
</shape>For a shape, start with attached drawables written before the geometry. Assemble outer box shadows, fill, inset box shadows and strokes, then the attachments written after the geometry. Attachment order For a group, assemble its children on transparency. For an active sequence, obtain its sampled picture. A nonempty source filter establishes this isolated input even on a pass-through owner and even for a sampled identity operation. Filter the resulting image in the owner's local coordinates, apply the owner's mask and opacity once, then transform and composite into the parent. A filter can extend pixels outside the original geometry. The scene viewport and any enclosing clips still apply. On a referenced sequence, the source scene clips its own picture before the placement filters it. Sound is independent of these operations. Spatial composition · Sequence clocks
Backdrop blur
A shape, group or sequence may own one backdrop-filter in addition to its source filter. It contains exactly one blur. Its nonnegative sigma, default zero, and its animation use the ordinary blur units and owner clock. Both filter declarations are properties of the drawable. Their XML positions do not determine their evaluation order.
At the owner's paint position, take the accumulated image D in its parent paint scope at the sampled instant. At the scene root this includes the background and earlier drawables. Inside an isolated owner it includes earlier painting in that picture. An unfiltered pass-through owner also exposes its enclosing backdrop to its contents. Inside a referenced scene the read starts with that scene's own background. A backdrop filter on the placement reads the enclosing scope. An inactive sequence contributes nothing. Sampling a standalone scene requires only its declared inputs.
Compute F by Gaussian convolution of D in premultiplied linear sRGB, including alpha, using the owner's local coordinates. The full local-to-picture map carries the kernel into picture space, including camera zoom and nonuniform scale. Clamp samples at a finite scene viewport edge. Empty parts of an isolated scope are transparent. The kernel may read past the edge of the affected geometry or mask. An allocation or tile edge introduces no sampling boundary.
For a shape, let g be coverage of its sampled filled geometry, including holes, independently of fill paint, stroke, shadow and attachments. For a group or sequence, require an explicit owner mask and use g = 1. A missing required mask, a duplicate backdrop filter, or any operation list other than one blur requires a diagnostic. Let w be its mask coverage (default one) times its opacity. Keep the existing source compositing behavior throughout the owner:
- Form the adjusted background A = mix(D, F, g) in premultiplied linear sRGB.
- Convert A to premultiplied encoded sRGB. Draw the owner onto A according to its layer blend mode and source scope to obtain C.
- Replace the destination with mix(D, C, w) in that same premultiplied encoded space. Apply w once to all four channels.
A zero sigma gives the ordinary source compositing result. A transparent panel can blur through its geometry. Its source shadow can extend beyond that geometry. A geometry mask or boolean operand reads only geometry. When rendering a mask's visual source, evaluate it in its own transparent scope.
In the panel case, resize one rectangle to move the tint and blur boundary together. Edit the blur's sigma to soften the plate, or edit the separate source shadow to move the panel's shadow. CSS also gives a drawable a backdrop effect and an independent source effect. SVG 1.1 exposes image inputs on individual graph primitives. An After Effects adjustment layer gives the effect its own position in the layer stack. The panel edit needs one geometry owner and two independently editable effects. CSS backdrop filters · SVG filter inputs · After Effects adjustment layers
Operations
| Operation | Meaning |
|---|---|
blur | Convolve premultiplied linear-sRGB color and alpha with a normalized, isotropic Gaussian. Source blur samples transparent black beyond the input. Backdrop blur uses its scope’s sampling boundary. |
drop-shadow | Blur the input alpha, offset it by dx and dy, and multiply it by the alpha of color. Tint with that color's RGB. Composite the original input over this shadow in linear sRGB. The next operation sees both. |
inner-shadow | Tint the preceding image along the inside of its alpha silhouette, including around holes. Preserve its alpha at every pixel. Positive dx shades the left inside edge of an opaque vertical bar. |
For an inner shadow, let A be the input alpha and B its Gaussian blur offset by (dx, dy), with zero beyond the input before convolution. Set q = color.alpha × (1 − B). For input premultiplied linear-sRGB color P and straight linear shadow color C, output ((1 − q) × P + q × A × C, A). A fully transparent input stays transparent. A translucent region can receive tint throughout, even with zero blur and offset. The next operation receives this whole image.
All Gaussian blurs, including box shadows, take the same nonnegative sigma in local units. Zero copies the input to the blur stage. A zero-sigma shadow has a sharp edge. dx and dy are finite signed local lengths, right and down positive. These three lengths default to zero. Each shadow requires an explicit color="#RRGGBBAA" in encoded sRGB. Convert colors to the working space for filtering. Offsets, spread, sigma and color can each own an ordinary property track. A placement's filter samples on the placement's parent clock, and filters within its source sample on the source clock. Property animation
Outer box shadows
A shape with rectangle geometry may own any number of box-shadow children. Each uses the same sampled, untransformed rectangle, including its used corner radii. The caster is opaque geometry even where the rectangle's fill is transparent. The default inset="false" draws the outer shadows behind the fill. Paint shadows of the same kind in document order, later over earlier.
- Expand the rectangle outwards on each side by
spread, a signed local length with default zero. A negative value contracts the caster. A zero-area original or collapsed caster casts no shadow. - Keep square corners square. Add the spread to each other used radius, floor it at zero, and apply the rectangle's proportional fit rule to the resulting radii. Rectangle corners
- Blur the caster coverage with
sigma, offset bydxanddy, and tint as for a drop shadow. Exclude the original rounded rectangle's interior from the result, including when the shape has no fill. Each box shadow samples its own caster independently.
Inset box shadows
With inset="true", the same rounded rectangle defines an opening in an opaque plane. Start from the used corner radii and resize the opening using the outer-shadow rules above with the sign of spread reversed. Positive spread makes the inner band thicker. Blur the opening coverage, shift it by the authored offsets, and tint its complement with the shadow color. Clip the result to the original rounded rectangle. A collapsed opening shades the entire original rectangle. A zero-area original draws nothing.
Paint inset shadows above the fill and below every stroke. An unfilled rectangle can therefore show an inset shadow. Its opacity comes from geometry and shadow color. In contrast, an image inner-shadow preserves the alpha of its input. The inset boolean accepts the discrete hold tracks used by other enumerated properties.
A geometry mask or boolean operand reads geometry alone. An alpha or luminance mask reads the rendered shape, including its shadows and filter. Mask coverage
For interchange, copy an isotropic SVG Gaussian standard deviation or CSS filter blur length to sigma. A CSS box shadow with blur radius 16 uses a reference Gaussian with sigma 8. CSS lists the foremost box shadow first, so reverse its list when mapping overlapping shadows. Verify spread and corner geometry on import. CSS shadow blurring · CSS filters