Jump to content
  • Advertisement
Sign in to follow this  
vitefalcon

How to turn off pixel interpolation?

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

Advertisement
By 'interpolated', I assume you mean filtered. Two points:

If the destination surface is exactly the same size as the source texture, you can achieve 1-1 texel-pixel mapping by offsetting the texture coordinates by 0.5 pixels. This page has some details.

If the destination isn't the same size as the source, but you still want to avoid the default linear filtering that occurs, then you can tell the sampler to use a 'nearest' filter. If you never want said texture to be filtered, you should create it using D3DTEXF_POINT, assuming you use D3DXCreateTexture*. Alternatively, you can call IDirect3DDevice9::SetSamplerState with D3DSAMP_MINFILTER and/or D3DSAMP_MAGFILTER set to D3DTEXF_POINT before rendering.

Regards
Admiral

Share this post


Link to post
Share on other sites
i'm rendering a TransformedColored vertex.. (a rectangle) texture is not a part of the rendering... would the min and mag filter still help?

Share this post


Link to post
Share on other sites
Quote:
Original post by vitefalcon
i'm rendering a TransformedColored vertex.. (a rectangle) texture is not a part of the rendering... would the min and mag filter still help?

What exactly gets interpolated? Are you trying to enlarge the 2x2 to view it, and that gets filtered? Or perhaps the colours are interpolated, but not the right way?

Share this post


Link to post
Share on other sites
I am tring to render a 2x2 texture on with a RenderToSurface object which is initialized with the same dimensions. Now... i hav a mesh like this

CustomVertex.TransformedColored[] verts = {
new CustomVertex.TransformedColored(0.0f, 0.0f, 0.0f, 1.0f, Color.Red.ToArgb()),
new CustomVertex.TransformedColored(0.0f, 1.0f, 0.0f, 1.0f, Color.Blue.ToArgb()),
new CustomVertex.TransformedColored(1.0f, 1.0f, 0.0f, 1.0f, Color.Magenta.ToArgb()),
new CustomVertex.TransformedColored(0.0f, 0.0f, 0.0f, 1.0f, Color.Red.ToArgb()),
new CustomVertex.TransformedColored(1.0f, 1.0f, 0.0f, 1.0f, Color.Magenta.ToArgb()),
new CustomVertex.TransformedColored(1.0f, 0.0f, 0.0f, 1.0f, new ColorValue(1.0f,1.0f,1.0f,1.0f).ToArgb())};

It is not clipping that's affecting this.. i'm sure of it coz i tried making the render target bigger and rendered the same... got only one pixel rendered (the red one)... But if i make the mesh bigger it gets rendered but due to linear interpolation of colors (in the pipeline i guess) when i read back from texture i get wrong values of the color.The red is always correct but not the rest of them. I'm doing this as a part of my larger project and for that i need to stop this interpolation of colors so that i can read the color value in it which is not corrupted by the interpolation.

Share this post


Link to post
Share on other sites
The discussion in the docs under "Directly Mapping Texels to Pixels" and "Rasterization Rules" might be helpful. (These are in the C++ docs. Don't know if there are matching managed docs pages.)

I don't know if they really apply to this, but playing with coordinates a bit might help here, too.

As for what you're trying to do, note that interpolation is part of rendering, and if you'll draw anything bigger you're likely to see it anyway. If you're just drawing 2x2, then it may be easier to just write the colours into the surface.

Share this post


Link to post
Share on other sites
When rendering colored vertices the graphics card interpolates the color inbetween vertices. One solution might be to make separate triangles for each color section, having all the vertices of each triangle the same color.

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!