Jump to content
  • Advertisement
Sign in to follow this  

Help with faulty HLSL ps_2_b edge-enhancement shader

This topic is 2279 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 :

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 )

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.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!