locked
WPF effects similar to Blur RRS feed

  • Question

  • Could someone help me with the new HLSL effects in WPF? Basically I need an HLSL Glow effect, to replace the BitmapEffect one.

    I could figure out by myself that the PaddingTop, PaddingLeft, etc. properties let you create effects, which "overflow" the Visual bounding box (BTW, why not a simple Padding property, as everywhere else in WPF?)

    Creating a glow effect needs some blurring for the soft edges.  But here I don't have a clue how to perform that efficiently and in a parameterized fashion.

    I thought I would have a look at the two effects shipped with WPF: DropShadow and Blur. Both are doing exactly what I need, that is they have a blur built-in. Moreover they are very flexible and can be configured for radius, [box - gaussian], and [fast - quality]. But looking inside .NET I discovered that they don't seem to actually use a pixel shader as we are supposed to... They do some fancy calls to the MIL composition engine, which I don't understand.

    I honestly hope we could build a Blur effect similar to the one shipped by MS. If they used some internals we don't have access to I would be very disappointed.

    Can somebody here help me?
    Sunday, September 14, 2008 7:22 PM

Answers

  • We're aware of the limitations of the current ShaderEffects.  Glow is tricky because, like drop shadow, you really need multiple passes to make it work correctly (since you are composing the original content and a blurred / color-filtered copy).  Both drop shadow and blur were implemented internally as optimized multi-pass shaders in our native graphics dll and that cannot be duplicated directly using the managed ShaderEffect API.  We definitely want to expand what can be done here in the future.  In the meantime, you can approximate multi-pass effects by applying more than one Effect at different levels in the Visual tree.  You should be able to create some sort of glow effect similar to the one in V1 using this technique - it just isn't easy to modularize into a single ShaderEffect that can be shared since the support for multiple passes isn't there. 

    • Proposed as answer by Jim Zhou - MSFT Friday, September 19, 2008 2:15 AM
    • Marked as answer by Marco Zhou Friday, September 19, 2008 12:15 PM
    Wednesday, September 17, 2008 8:13 PM

All replies

  • We're aware of the limitations of the current ShaderEffects.  Glow is tricky because, like drop shadow, you really need multiple passes to make it work correctly (since you are composing the original content and a blurred / color-filtered copy).  Both drop shadow and blur were implemented internally as optimized multi-pass shaders in our native graphics dll and that cannot be duplicated directly using the managed ShaderEffect API.  We definitely want to expand what can be done here in the future.  In the meantime, you can approximate multi-pass effects by applying more than one Effect at different levels in the Visual tree.  You should be able to create some sort of glow effect similar to the one in V1 using this technique - it just isn't easy to modularize into a single ShaderEffect that can be shared since the support for multiple passes isn't there. 

    • Proposed as answer by Jim Zhou - MSFT Friday, September 19, 2008 2:15 AM
    • Marked as answer by Marco Zhou Friday, September 19, 2008 12:15 PM
    Wednesday, September 17, 2008 8:13 PM
  • Wow, that's disapointing. It's really sad that MS is showing off with HW-optimized demo of blurred scenes, when it's in fact impossible to reproduce without relying on the built-in effects (of which there are extremely few: 2).

    Hopefully the situation will improve with the next framework release...
    In the meantime I'm a bit stuck but I'll try to find some workarounds.

    Thanks for your reply,
    jods
    Wednesday, September 17, 2008 9:29 PM
  • Monday, October 18, 2010 11:05 PM