Sign in to follow this  

Help with faulty HLSL ps_2_b edge-enhancement shader

This topic is 2062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've written a simple edge-enhancement filter for video with HLSL , and for some reason it has absolutely no effect :

[CODE]
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);
}
[/CODE]

When I just display pdiff on the screen , I get a black screen ( obviously something isn't working )

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

This topic is 2062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this