PDA

View Full Version : mipmaping and NPOT textures



Osbios
08-09-2013, 12:22 PM
I have minor trouble understanding in what way mipmaping works for NPOT textures.

According to the reference each mipmap level size for 2d textures is
mipmapSizeX = max(1, floor(textureSizeX / pow(2, mipmapLevel)))
mipmapSizeY = max(1, floor(textureSizeY / pow(2, mipmapLevel)))

So for a 128x128 texture, the mipmap level 1 size would be 64x64.

And for a 127x127 texture, it would be 63x63.
Because there is no direct 4 to 1 mapping of the textels anymore, I suppose it just gets blitted with a linear filter, is that correct?

Does the fetching of the mipmap level 1 then exactly work like fetching from a 63x63 texture? I mean in the context of normalized texCoords to texel positions.

GClements
08-09-2013, 05:49 PM
Because there is no direct 4 to 1 mapping of the textels anymore, I suppose it just gets blitted with a linear filter, is that correct?
Selection of and interpolation between mipmap levels and bilinear interpolation within a mipmap level are two different issues. Provided that the implementation supports NPoT textures, there is nothing special about the case of power-of-two sizes.


Does the fetching of the mipmap level 1 then exactly work like fetching from a 63x63 texture? I mean in the context of normalized texCoords to texel positions.
Yes.

Ignoring wrapping, for the *_NEAREST modes, the texel at (floor(s*w),floor(t*h)) is chosen, where w and h are the width and height of the mipmap level.

For the *_LINEAR modes, the four texels at (floor(s*w-0.5)+i,floor(t*h-0.5)+j) for i and j in {0,1} are chosen, and the fractional parts of (s*w-0.5) and (t*h-0.5) are used as interpolants.