Okay this is what I've got so far.

I've got a shader based on the horizontal gaussian blur shader that can be 
found at 
http://www.adobe.com/devnet/flex/articles/pixel_bender_basics_flex_air.html

Its been altered to have two inputs (one for background and one per foreground 
as per 
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WSB19E965E-CCD2-4174-8077-8E5D0141A4A8.html

the shader is as follows: 

<languageVersion: 1.0;>

kernel HorizontalGaussianBlur
<   namespace : "com.adobe.example";
    vendor : "Adobe Systems Inc.";
    version : 1;
    description : "The horizontal convolution of a Gaussian blur"; >
{
    input image4 background;
    input image4 foreground;
    output pixel4 dst;

    void evaluatePixel()
    {
       pixel4 center, band1, band2, band3, band4, band5, band6;
       float2 pos = outCoord();
       int radius = 6;
       //Sample image in bands
       if( radius > 5 )
       {
            band4 = sampleNearest(background, float2(pos.x - 6.0, pos.y)) 
                  + sampleNearest(background, float2(pos.x + 6.0, pos.y));
       } 
       if( radius > 4 )
       {
            band4 = sampleNearest(background, float2(pos.x - 5.0, pos.y)) 
                  + sampleNearest(background, float2(pos.x + 5.0, pos.y));
       }        
       if( radius > 3 )
       {
            band4 = sampleNearest(background, float2(pos.x - 4.0, pos.y)) 
                  + sampleNearest(background, float2(pos.x + 4.0, pos.y));
       }       
       if( radius > 2 )
       {
            band3 = sampleNearest(background, float2(pos.x - 3.0, pos.y)) 
                  + sampleNearest(background, float2(pos.x + 3.0, pos.y));
       }
       if( radius > 1 )
       {
            band2 = sampleNearest(background, float2(pos.x - 2.0, pos.y)) 
                  + sampleNearest(background, float2(pos.x + 2.0, pos.y));
       }

       band1 = sampleNearest(background, float2(pos.x - 1.0, pos.y)) 
             + sampleNearest(background, float2(pos.x + 1.0, pos.y));
       center = sampleNearest(background, pos);
       
       //Apply weights and compute resulting pixel
       if( radius == 6 )
       {
            dst = (band6 + (band5 * 12.0) + (band4 * 66.0) + (band3 * 220.0) + 
(band2 * 495.0) + (band1 * 792.0) + (center * 924.0))/4096.0;
       }
       if( radius == 5 )
       {
            dst = (band5 + (band4 * 10.0) + (band3 * 45.0) + (band2 * 120.0) + 
(band1 * 210.0) + (center * 252.0))/1024.0;
       }       
       if( radius == 4 )
       {
            dst = (band4 + (band3 * 8.0) + (band2 * 28.0) + (band1 * 56.0) + 
(center * 70.0))/256.0;
       }
       if( radius == 3 )
       {
            dst = (band3 + (band2 * 6.0) + (band1 * 15.0) + (center * 
20.0))/64.0;
       }
       if( radius == 2 )
       {
            dst = (band2 + (band1 * 4.0) + (center * 6.0))/16.0;
       }
       if( radius == 1 )
       {
            dst = (band1 + (center * 2.0))/4.0;
       }
    }
}

I've then tried applying to a component.  which gives the following error.

ArgumentError: Error #2167: The Shader does not have the required number of 
inputs for this operation.
        at flash.display::DisplayObject/set blendShader()
        at 
mx.binding::Binding/defaultDestFunc()[E:\dev\4.y\frameworks\projects\framework\src\mx\binding\Binding.as:282]
        at Function/http://adobe.com/AS3/2006/builtin::call()
        at 
mx.binding::Binding/innerExecute()[E:\dev\4.y\frameworks\projects\framework\src\mx\binding\Binding.as:485]
        at Function/http://adobe.com/AS3/2006/builtin::apply()
        at 
mx.binding::Binding/wrapFunctionCall()[E:\dev\4.y\frameworks\projects\framework\src\mx\binding\Binding.as:395]
        at 
mx.binding::Binding/execute()[E:\dev\4.y\frameworks\projects\framework\src\mx\binding\Binding.as:333]
        at 
mx.binding::BindingManager$/executeBindings()[E:\dev\4.y\frameworks\projects\framework\src\mx\binding\BindingManager.as:153]

but as far as I can see there are two inputs and according to the page listed 
above when using a shader as a blender it needs two inputs. (I'm only using one 
input the foreground one is being ignored) any ideas?



--- In flexcoders@yahoogroups.com, Wes <wesley.acheson@...> wrote:
>
> Hi.
> 
> I'm wondering if there is any way to blur the contents behind a component. 
> Similiar to how an alert box works but not the entire display. I think that 
> it should be possible based on a couple of facts.
> 
> 1 blendmode means that a component must be able to know the visuals behind it.
> 2 even changing an alpha must mean the player is aware of underlying visuals 
> as there are pixel maths involved.
> 3 blend modes which are not native to the flash player are implemented as 
> shaders.
> 4 gaussian blur could be implemented as a custom shader if necessary.
> 
> I have seen AS2 implementations but they rely on getting a bitmap of an 
> entire background. This obviously doesn't work with overlapping components.
> 
> Ideally for simplicity I'd do this as a custom background on a spark 
> titlewindow component. Initially as this can be dragged arround.
> 
> If this can't be implemented as a shader is there any way to link the size 
> and position of two unrelated components. This would be useful for 
> underlays/overlaying
> 
> Wes
> 
> Sent from my Kindle Fire
>

Reply via email to