Jump to content
stanislas69

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

Share this post


Link to post
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

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites
3 minutes ago, stanislas69 said:

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

I agree to use POT textures, until we have a better solution.

Share this post


Link to post
Share on other sites

NPOT doesn't work on ATI. Really it doesn't work well in general, and is not something we should encourage. Packing into an atlas does fix that though.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×