Aliasing on non-power-of-2 textures

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
impulse3d
Posts: 17
Joined: Wed Jun 04, 2008 7:23 pm

Aliasing on non-power-of-2 textures

Post by impulse3d »

I'm trying to blit a full-screen image using draw2DImage. I'm using non-power-of-2 screen size and texture size. However, it still doesn't draw 1-to-1; I think it resizes it down to a power of 2, and then upsamples it to fit the window. I've been doing a lot of work with Irrlicht over the past two months, and this just seems to be a limitation of the drivers. I've done a lot of searching on the forums, and can't find anyone who's had success with that. Can you "correctly" draw an image of a non-power-of-2 texture?

Original image:
Image

Image in Irrlicht:
Image

If not, I'm willing to compromise with a filtered image. However, I've been unable to figure out how to turn on bi/trilinear filtering for the draw2DImage function. I've tried

Code: Select all

SMaterial mat;
mat.setFlag(EMF_BILINEAR_FILTER, true);
driver->setMaterial(mat);
driver->draw2DImage(...);
but that doesn't seem to have any effect. How can I turn on bi/trilinear filtering for images displayed using draw2DImage?

Thanks for any help.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah irrlicht will upscale a NPOT image to the nearest POT dimension. I thought maybe it didn't do it if the graphics card supported NPOT textures, but maybe it just does it as standard. And really you can't just rely on your gfx supporting NPOT textures as your users may not have a gfx card that also supports NPOT textures.

What you can do though is just make your texture POT dimensions, by using padding around the edges and then draw just the necessary rectangle, ignoring the padding.
Image Image Image
impulse3d
Posts: 17
Joined: Wed Jun 04, 2008 7:23 pm

Post by impulse3d »

Okay, great JP. This solution works well. Thanks! I've made my texture a POT texture and used a clip rectangle that is 1-to-1 with the screen.

Now the only other thing I'm wondering is if we can get it to display well on resolutions other than 1-to-1 imageclip:window resolutions (i.e. requiring an image scale). Here is where I'd want to turn on texture filtering, but as I said I'm not sure if what I've tried is working (turning it on and off seems to have no effect on the image).

Is there an already established way to work around the problem of displaying scaled images? And how can I turn on filtering of textures so that scales look better?

Thanks again. :D
Post Reply