Question

How to create Simple HLSL Silverlight filter for blending/playing with/mixing 2 images?

I need some working example of a filter which would take as an input 2 images\objects and return 1 image - result of some calculations.

I want to bring to Silverlight blend modes!)

Was it helpful?

Solution

Well the first thing you would do is define a .FX file. In that you need code like the following:

uniform extern texture Image1;
uniform extern texture Image2;
sampler2D BG_Image1_Sampler = sampler_state
{
    Texture = (Image1);
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
};
sampler2D BG_Image2_Sampler = sampler_state
{
    Texture = (Image2);
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
};

float4 MyCalcFunction(float2 TexCoords : TEXCOORD0) : COLOR0
{
    float4 outColor;
    //calculations here

    return outColor;
}

technique BlurGlow
{
    pass P0
    {
        PixelShader = compile ps_2_0 MyCalcFunction();
    }
}

I'm unsure of how to use the FX file with silverlight but that should get you started!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top