Jump to content
  • Advertisement
Sign in to follow this  

Post Processing Texel Offsets

This topic is 2800 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

Hi guys, I'm trying to do a simple horizontal blur filter. I don't understand what to use for the texture coordinate values.

This is from the DirectX PostProcess sample:

// what the hell is this ?
float2 TexelKernel[g_cKernelSize]
string ConvertPixelsToTexels = "PixelKernel";

// pixel shader part
float4 Color = 0;

for(int i=0;i<g_cKernelSize;i++){
Color += tex2D( g_samSrcColor, Tex + TexelKernel.xy ) * BlurWeights;

I am pretty sure a texel is either:


(which one ?)

...so is the TexelKernel x-values for a 5-sample filter simply:

TexelKernel[0].x= -2*texel;
TexelKernel[1].x= -1*texel;
TexelKernel[2].x= 0;
TexelKernel[3].x= 1*texel;
TexelKernel[4].x= 2*texel;


Share this post

Link to post
Share on other sites


That one.

There is a small difference in the alignment of pixels and texels.
If you are using D3D9, you may want to look at this.
Or if you are using D3D10+ then look at this.

If you use Dx10+ you can consider using the Load intrinsic. It allows fetching data without filtering or sampling and is thus much faster if you want to access texels directly. Small sample:
inputTexture.Load(int3(input.Position.xy, 0));

The position argument of the Load intrinsic is in integers, which means in [0…width-1]x[0…height-1]. The xy component of the SV_Position gives you in a pixel shader the position of the current pixel in device coordinates (with a half texel offset but that will be truncated if you cast it to int.)

Hope it helps. smile.png

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!