Page 1 of 1

Aliasing on non-power-of-2 textures

Posted: Fri Jul 18, 2008 2:25 pm
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.

Posted: Fri Jul 18, 2008 2:31 pm
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.

Posted: Fri Jul 18, 2008 2:49 pm
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