el_BA
Topic Author
Posts: 8
Joined: 28 May 2024, 07:15
Location: Melbourne, Australia

How to add BackgroundEffectBehavior on text?

24 Nov 2026, 00:39

Hi all!

We're currently trying to get some effects on TextBlocks (specifically the overlay blending mode, which isn't supported unfortunately. I've talked to our graphics programmer and we can't add overlay ourselves either). I thought that maybe I could utilise the BackgroundEffectBehavior but it doesn't support text.

I'm happy to make my own custom behaviour which replicates the OG BackgroundEffectBehaviour but also supports text, but I'm unsure how to go about it -- I can find the bounds of the text, but not of the glyphs themselves. Is this possible? Is there another way I could achieve the Overlay blending mode on TextBlocks or do I have to tell the artists that this effect is unachievable? :(

Thanks in advance guys!
El Perrin, UI Technical Artist @ Big Ant Studios
 
User avatar
jsantos
Site Admin
Posts: 4843
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to add BackgroundEffectBehavior on text?

24 Nov 2026, 14:46

Hello!

Support for the Overlay blending mode has been discussed several times here. Without hardware support (using KHR_blend_equation_advanced, which is not widely adopted), it is difficult to implement it without introducing performance issues.

In the past, some of our clients have used the following workarounds:

- A two-pass approach using Multiply + Screen. This can produce acceptable results in some scenarios, although it does not accurately reproduce the Overlay blending mode.
- A more sophisticated two-pass approach, as described here. This requires floating-point render targets and is still an approximation. Can be done with Noesis with a few minimal changes in the renderer.

Using BackgroundEffectBehaviour (extending it to support text) is another option, although it has some limitations:

- It works well as long as you don't need to blend with your engine's 3D scene. Otherwise, a copy of the 3D scene would be required, which is inefficient.
- The text fill should be a solid color or something that can be passed directly to the shader as a parameter.
- BackgroundEffectBehavior requires requires two offscreen passes because it is designed to work as an effect. However, Overlay blending could be implemented with a single offscreen pass. We could potentially implement a BackgroundBrushBehaviour specifically for this purpose.

Could you please give us more detail about your scenario?
 
el_BA
Topic Author
Posts: 8
Joined: 28 May 2024, 07:15
Location: Melbourne, Australia

Re: How to add BackgroundEffectBehavior on text?

Yesterday, 02:14

Thanks for your reply!

I believe I've found a workaround by making a blend mode shader that uses utilises the BackgroundEffectBehaviour. it works flawlessly with shapes and panels etc which are supported for the behaviour, but I've done something super hacky to get it to work with text:
 <Rectangle Width="{Binding ElementName=TB, Path=ActualHeight}" Height="{Binding ElementName=TB, Path=ActualWidth}" Margin="200,0" HorizontalAlignment="Right" Fill="Black" RenderTransformOrigin="0.5,0.5" Visibility="Visible"> 
     <Rectangle.OpacityMask>
         <VisualBrush Stretch="Fill"
                      Visual="{Binding ElementName=TB}"/>
         </VisualBrush>
     </Rectangle.OpacityMask>
     <b:Interaction.Behaviors>
         <noesis:BackgroundEffectBehavior Source="{Binding ElementName=BG, Mode=OneWay}">
             <noesis:BackgroundEffectBehavior.Effect>
                 <paEx:BlendShader BlendMode="{x:Static Enums:BlendMode.Overlay}"
                                           Colour="{StaticResource WhiteCol}" />
             </noesis:BackgroundEffectBehavior.Effect>
         </noesis:BackgroundEffectBehavior>
     </b:Interaction.Behaviors>
 </Rectangle>
 
And it works! Very hacky though :(
But yes, managed to get a shader working for blend modes really well -- now my only huge setback is the text support, but I have a way around it ¯\_(ツ)_/¯
El Perrin, UI Technical Artist @ Big Ant Studios
 
User avatar
jsantos
Site Admin
Posts: 4843
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to add BackgroundEffectBehavior on text?

Today, 14:51

Nice workaround! :) Thanks for sharing.

We should find a better long-term solution for this.

Do you mind creating a ticket so we can continue the discussion there and explore potential implementations?

Thank you!

Who is online

Users browsing this forum: No registered users and 17 guests