Offset texture by half pixel

I need to offset a texture in a material by a half pixel so that it renders correctly for something I’m doing.
here is a good explanation of what I need Half-Pixel Offset in DirectX 11

Whats the easiest way to go about this?

Bump – I could also use this. should be a feature.

Hey xdbxdbx -

You can try this math, I know it will work with a Screen Size rendered image, but you might need some additional math to determine the correct texel size and do a comparison to the pixels per texel before the pixel math.

Thank You

Eric Ketchum

yeah, thats similar to what I ended up doing except I have to pass in the texture dimensions everywhere.

can you put in a request for a texture dimension node?
then it should be trivial to make a function out of it to do this.

much appreciated on the quick reply!

Hey xdbxdbx -

I want to try to get this feature request in for you correctly. The Texture dimension node you mention would be a Texture Coordinate as the engine sees all textures in relation to the 0 to 1 space. I think you want a node that will read the texel location in pixel space. Is that correct? Giving me an exact reference to how you want to use it can be helpful as well

Let me know -

Eric Ketchum

sure, I can envision several ways I can go about obtaining my results. so possibly several requests for you to add. at the core of it, item 1 is at the heart of what makes things trivial in the material graph. hopefully they are trivial to implement as well. I think everyone will benefit from this greatly.

  1. A texture resolution node. input a texture, outputs a vector with the dimensions of the texture. ex: 512x512. lets not forget some people might want to use 1D and 3D textures as well. This will save us from manually having to setup and send these parameters from blueprints (and making mistakes!).

  2. a texel resolution node (material function?). This would output the equivalent of 1 divided by the texture dimensions mentioned in item 1 above (giving us the size of 1 texel for a given texture). this will make it easy to shift textures around by pixel…err texel value. ex: texture coordinates.x + texel resolution.x * 5 would produce texture coordinates where you have shifted a texture by 5 units in its own space. I’m sure others will find more creative uses.

  3. while at it, maybe the programmer adding these can make that example in item 2 a built in texel shift material function? Seems trivial to build on the requested changes. A function that takes in a texture and a shift amount for texels, Outputs texture coordinates shifted by such amount. myself and many others are going to use this and input 0.5 to correct for the texture wrap around bleed mentioned in the original question. internally it would perform texture coordinate + texel resolution * texel offset amount and return those results.

All in all, if we get all this, it will condense the math you did above to possibly a single node without the need to manually setup parameters from blueprints.
I’m looking forward to using such a simplified system.

Hey xdbxdbx -

Thank You for teh additional information. I have passed the information along to our engineers for further investigation and consideration. As soon as I hear anything I will report back to you here.

Eric Ketchum