Seaside Studios
HomeOverviewFAQsContactReview
Sprite Shader
Sprite Shader
  • What is All In 1 Sprite Shader
  • Overview
  • First Steps (Must Read)
  • Render Pipeline And Post Processing Setup
  • Asset Component Features
  • Right Click Create Material
  • Asset Window
  • Textures Setup
  • Custom Sort Axis
  • Saving Prefabs
  • Sprite Atlases
  • How to animate effects
  • Scripting
  • How to Enable/Disable Effects at Runtime
  • Random Seed
  • Scaled Time
  • UI Masking
  • 2D Renderer URP Lights
  • 3D Lights
  • Unified Outline
  • Render Material To Image
  • Compatibility with other assets
  • Effects and Properties Breakdown
  • Considerations
  • Running out of Shader Keywords
  • FAQ (Frequently Asked Questions)
Powered by GitBook
On this page

UI Masking

PreviousScaled TimeNext2D Renderer URP Lights

Last updated 8 months ago

Video about it:

If you try to use the asset material on a masked UI element such as the ones contained on a Scroll view you’ll see that the object won’t get masked.

In this image we can see how we have a UI image inside of a Scroll View and it’s not getting masked (it should only be visible inside the gray area). This happens because elements that need to be masked have a unique Stencil configuration, this configuration is not included on the default material since it would bring problems to the regular use cases.

But you can change the shader variant with the shader component and the Image will get masked:

Sometimes for this to take effect in the scene you’ll need to Save the scene (Ctrl+S). Same happens when modifying shader properties through the inspector. Another caveat is that, as already mentioned in the Scripting section above you will want to use Image.materialForRendering instead of Image.material when scripting UI Masked UI Images.

*For this to work the Stencil buffer must be enabled. In the Built-In pipeline is enabled by default in most platforms. In case you are building for Android you can go to Player Settings, Resolution and Presentation and make sure that the Stencil isn’t disabled. In URP you need to enable the stencil in the Pipeline Settings asset: