Help with faulty HLSL ps_2_b edge-enhancement shader

Started by
1 comment, last by DannyZB 12 years ago
I've written a simple edge-enhancement filter for video with HLSL , and for some reason it has absolutely no effect :


Texture2D FirstTexture : register(t0);
sampler2D tex0 : register(S0) = sampler_state
{
Texture = <FirstTexture>;
};
float4 main(float2 uv : TEXCOORD) : COLOR
{
// Laplacian edge-enhancement using a 4-connected grid
float4 p10 = tex2D(tex0, float2(uv.x,uv.y-1));

float4 p01 = tex2D(tex0, float2(uv.x-1,uv.y));
float4 p11 = tex2D(tex0, float2(uv.x,uv.y));
float4 p21 = tex2D(tex0, float2(uv.x+1,uv.y));

float4 p12 = tex2D(tex0, float2(uv.x,uv.y+1));

float4 pdiff = p11*4 - p10 - p01 - p21 - p12;

float4 pixelColor = p11 + pdiff*2;

return saturate(pixelColor);
}


When I just display pdiff on the screen , I get a black screen ( obviously something isn't working )
Advertisement
Are you trying to access the adjacent texels with -1 and +1?

You should divide the value by the texture size in order to get the adjacent texel.

If you can use HLSL 4, you may use load command with integer offsets to access individual samples.

Cheers!
Oh thanks a lot ! works perfectly (:
Noob mistake

This topic is closed to new replies.

Advertisement