Jump to content

Script to find non power of two textures


Recommended Posts

 

@elexis I wrote this to check for dubious textures in case that can be of use.

from PIL import Image
import os

def is_power_of_two(n):
    return (n & (n - 1)) == 0

modList = ["public", "terra_magna"]

for mod in modList:
    listOfFiles = os.walk("E:\\Dev\\0-A-D\\ps\\trunk\\binaries\\data\\mods\\" + mod)
    for root, directories, filenames in listOfFiles:
        for filename in filenames: 
            if ".png" in filename:
                im = Image.open(os.path.join(root,filename))
                width, height = im.size
                if not is_power_of_two(width) or not is_power_of_two(height):
                    print("WARNING: Non power of two file found: " + os.path.join(root,filename))

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Yeah but I won't commit DDS. And the one we currently have are fine :)

15 minutes ago, vladislavbelov said:

As I mentioned problem is not in the texture resolution, but in number of mipmaps. Also we have not only .png textures.

True and that is defined by the textures XML files. Which by the current look them means we assume they are power of two.

The point of the script is not to fix textures its just a check . 

https://github.com/0ad/0ad/blob/e317fa0d610df3bf624aa326e979b2de7e75729a/source/lib/res/graphics/ogl_tex.cpp

According to this there were openGl limitations regarding the size of pictures.

 

  • Like 1
Link to comment
Share on other sites

4 minutes ago, vladislavbelov said:

OpenGL supports such textures since 2.0: https://www.khronos.org/opengl/wiki/NPOT_Texture. I think we need to have NPOT textures for UI, but then pack them into POT atlas. It should be faster and work better. It'd be good to implement after the GUI refactoring.

Then I guess It is a remnant of before openGl 2.0. still power of two textures Is good practice and really common.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...