Reputation: 310
I'm trying to use a pixel shader to disable specific channels on an image. Unfortunately, I can't seem to get my shader to work, nor do I know how to do step-through debugging on this. I've tried PIX for windows, but haven't gotten any success with that tool.
Here's my shader file: ChannelEffect .fx
sampler2D implicitInputSampler : register(S0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
// Get the source color
float4 color = tex2D(implicitInputSampler, uv);
color.g = 0.0f;
color.b = 0.0f;
// Return new color
return color;
}
Right now I'm hard-coding the channels I'm disabling, just to test it. This sample should make only the red channel appear.
ChannelEffect channelEffect = GetChannelEffect(displayChannel);
image.Effect = channelEffect;
dc.DrawImage(image.Source, destRect);
The end result I get is that the image renders as normal. Its as if I'm not even applying a shader at all. Any ideas?
Upvotes: 0
Views: 171
Reputation: 5183
I was doing something similar- and found Shazzam which is a fantastic program that not only will allow you to tweak and twiddle with shaders but will even generate code for you. I didn't use that code myself, but it gives a great example on how to use shaders with C# and XAML.
You can even import your own images to test with until you get your shader code exactly right.
Upvotes: 1