跳至主要内容

Drop Shadow Filter Component

Overview

This component adds a visual shadow effect to the UI object it is applied to.

WebGL Demo

Properties

Component Screenshot

Property                            TypeRangeDefaultDetails
Shadow
    ModeEnumDefaultWhich mode to use when rendering the shadow. Options are:
Default - Standard drop shadow where shadow is cast behind.
Inset - Shadow is cast inside giving a sunken appearance.
Glow - a blurred version of the Graphic is rendered underneath - make sure the Color is a bright value.
Cutout Drop shadow with the source Graphic cut out from it.
    AngleFloat[0..360]135.0The angle that shadow is cast in degrees.
    DistanceFloat[0..256]8.0The distance in pixels that the shadow is cast.
    ColorColorBlackThe color of the shadow.
Blur
    Down SampleEnumAutoHow to downsample the texture before blurring. Downsampling gives improved performance, however the quality can be lower especially when animation the blur amount, but for still images it's usually not noticable. Options are:
Auto - Automatic downsampling will depend on the platform.
None - No downsampling.
Half - Downsample to half the size.
Quarter - Downsample to a quarter the size.
Eighth - Downsample to an eighth the size.
    BlurFloat[0..64]4.0The radius of the blur filter in pixels.
    HardnessFloat[0..2]1.0Makes the shadow darker or lighter.
Apply
    Source AlphaFloat[0..1]1.0Fades the source Graphic.
    StrengthFloat[0..1]1.0Strength of the effect.
    Render SpaceEnumCanvasWhich coordinate system use when rendering this filter. Options are:
Canvas: Render the filter before any transforms (scale/rotation/translation etc) are applied.
Screen: Render the filter after transforms have been applied. Read more about this property here.

Usage

Add this component to any GameObject that contains a UI Graphic component (eg Text, Image, RawImage, etc). The object will now render with a shadow.

Usage with TextMeshPro

To use this filter effect with TextMeshPro use the Filter Stack (TextMeshPro) component.

Render Space

The RenderSpace property effectively controls whether the Graphic filter is applied before or after the Transform is applied. There are two options:

  • Canvas - This is the default mode for all filters. In this mode the filter is rendered to the Graphic before it is transformed into screen-space by the local Transform and by the Canvas. This means that any changes or animations to the transform (or it's parents) will not cause the filter to re-render (unless Canvas has per-pixel mode enabled), which is a performance benefit! This also means that when the Graphic is rotated, the filter will not be aware of this, so the filter will rotate as well. Imagine as drop-shadow effect.
  • Screen - This was the default mode before version 1.8.0 was released. In this mode the filter is rendered to the Graphic after it is transformed into screne-space. This means that any changes or animations to the transform (or it's parents) will cause the filter to re-render which can become expensive. It has the advantage that it is possible to do some screen-aware options, such as clamping the filter to the edges of the screen, or extending an edge to the edge of the screen (for example in the Frame Filter component)

A summary of the differences:

FeatureCanvasScreen
Adjusting transform causes filter re-renderNo (unless Canvas has per-pixel mode enabled)Yes