Jump to content

  • Log In with Google      Sign In   
  • Create Account


Interpolation between pixels


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 15 April 2014 - 10:53 PM

Hi guys,

I am part way through coding my own DX9 framework for a simple 2D game.

I have coded with DX9 on and off for a few years now and have been using Game Maker Studio to rapid prototype my game. GM:S is starting to get a bit restrictive, so I am back onto my own engine again.

One thing I am not sure how to do is replicate GM's 'interpolation between pixels' option, which softens the image slightly and has the other benefit of not making lines look jaggy if they are resized to an uneven amount.

I would love to hear any thoughts on how this might be achieved.

Thanks in advance :)

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 6759

Like
2Likes
Like

Posted 15 April 2014 - 11:30 PM

The interpolation of pixels is called filtering and is a standard feature of your video hardware. In 2d games and GUIs you often want to avoid the softening and a 1:1 mapping. In this case you would sample the texture with nearest-filter (take the pixel values at the nearest texel position). The often used, and standard filtering in 3d games, is the linear filtering, which interpolate the pixel value depending on the 4 neighbor texels. Further on, if you have mipmapping (you want to scale your image down without flickering artifacts), then the hardware will interpolate not only the values of a single texture, but of two neighbor mipmap layers (a mipmap is a downsampled version of the same texture). This is standard, when using hardware rendering and comes at no costs.

 

In fact, even if coding only a 2d game, you use the 3d rendering capability of the hardware (z-coord is fix), just render your 2d sprites as 3d quads with fixed z-coord.


Edited by Ashaman73, 15 April 2014 - 11:32 PM.


#3 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 15 April 2014 - 11:41 PM

Thanks for your reply. Makes sense :)

So with the sampling, is this something you can just instruct directX to do or would you have to apply a shader to do this?

Thanks again for your help :)

#4 Ashaman73   Crossbones+   -  Reputation: 6759

Like
2Likes
Like

Posted 16 April 2014 - 01:14 AM


So with the sampling, is this something you can just instruct directX to do or would you have to apply a shader to do this?

No shader needed, it was one of the first hardware supported features and DX9 will have all support you need out-of-the-box, it is most likely only a simple flag you need to set. Best to start here.



#5 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 16 April 2014 - 03:15 AM

Nice! Thanks for the link :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS