The size of a mip map is max{floor(width / 2 ^ level), 1} x max{floor(height / 2 ^ level), 1}, where width x height is the size of the full-resolution image, level is the integer mip map level and the smallest mip map has 1 x 1 resolution. If regenerateMipMapLevels is called with custom mip map data, the mip map sizes are calculated in this function and separately in uploadTexture. uploadTexture calculates a size by floor(width / 2 ^ level) x floor(height / 2 ^ level).
Proposed changes
To support non-square textures, after this change, uploadTexture sets the mip map width or height to 1 if it is 0.
Use a texture pack to override the default_desert_sand.png texture with this 2x16 pixel texture:
In the Minetest settings, set the mip_map setting to sharp
Play Minetest and look at different nodes, especially at default's Desert Sand
Before the changes: Desert Sand nodes are black and in the inventory it's white.
After the changes: Desert Sand looks like the other nodes, i.e. the full resolution and inventory image show the texture and only the mip maps are cyan, which is supposed to happen with the code in my mipmap_custom_simple_fill branch.
Problem description
The size of a mip map is
max{floor(width / 2 ^ level), 1} x max{floor(height / 2 ^ level), 1}
, wherewidth x height
is the size of the full-resolution image,level
is the integer mip map level and the smallest mip map has1 x 1
resolution. IfregenerateMipMapLevels
is called with custom mip map data, the mip map sizes are calculated in this function and separately inuploadTexture
.uploadTexture
calculates a size byfloor(width / 2 ^ level) x floor(height / 2 ^ level)
.Proposed changes
To support non-square textures, after this change,
uploadTexture
sets the mip map width or height to1
if it is0
.How to test
default_desert_sand.png
texture with this 2x16 pixel texture:mip_map
setting tosharp
Before the changes: Desert Sand nodes are black and in the inventory it's white.
After the changes: Desert Sand looks like the other nodes, i.e. the full resolution and inventory image show the texture and only the mip maps are cyan, which is supposed to happen with the code in my mipmap_custom_simple_fill branch.