Resize Textures and UDIM
I like to use the “Resize Textures” features, but I also like to use UDIM. At the moment, the files are named in a way which is incompatible with UDIM, which is a shame.
Could you change the name transformation in a way that checks if the name ends on the typical UDIM range?
Another solution would be to make the resolution marker a prefix to the file name.
Comments (9)
-
repo owner -
reporter Sadly, this doesn’t work for me yet.
The resizing utility does not convert the *_1001” tiles, also the “_1002” tile is loaded as first one by “Change Resolution”.
-
repo owner Now it works for me. In the previous commit only the images were renamed, not the texture nodes, and it is the name of the latter that is used when udim materials are made.
I don’t understand what you mean by the last sentence, though.
-
reporter This still does not work for me.
I changed resized.py on my system, since I still got only the first tile of an image set when resizing:
if os.path.isfile(args.newfile) and not args.overwrite: print("%s already exists" % os.path.basename(args.newfile)) return # Check if file is UDIM if args.file[-8:-4]=="1001": udim=1 else: udim=0 # Loop until all files in the set are converted, stop when file does not exists. while (os.path.isfile(args.file)): img = cv2.imread(args.file, cv2.IMREAD_UNCHANGED) rows,cols = img.shape[0:2] newrows = max(4, int(factor*rows)) newcols = max(4, int(factor*cols)) newimg = cv2.resize(img, (newcols,newrows), interpolation=cv2.INTER_AREA) if len(newimg.shape) >= 3 and newimg.shape[2] >= 3: blue = newimg[:,:,0] green = newimg[:,:,1] red = newimg[:,:,2] if (blue == green).all() and (blue == red).all(): print("Greyscale", args.file) newimg = cv2.cvtColor(newimg, cv2.COLOR_BGR2GRAY) print("%s: (%d, %d) => (%d %d)" % (os.path.basename(args.newfile), rows, cols, newrows, newcols)) cv2.imwrite(os.path.join(args.file, args.newfile), newimg) # Increase UDIM Tile (works only for up to 9 tiles, should be enough for DAZ) # No filename for next run if not UDIM if (udim): args.file=args.file[:-5]+str(int(args.file[-5:-4])+1)+args.file[-4:] args.newfile=args.newfile[:-5]+str(int(args.newfile[-5:-4])+1)+args.newfile[-4:] else: args.file="" main()
This way, resize looks for all UDIM tiles when given the first tile.
-
reporter After conversion, the code in “Change Resolution” does not work properly with UDIM textures.
after changing the resolution the resulting Image always has Source=”Single Image” in the Data API, not Source=”UDIM”.
When I change to a new resolution, it will always be loaded as Source=”Single Image”. not as Source=”UDIM”
The original image will have a name with the extension added to it (“image.tif” or “image.jpg” instead of “image” in “Name”)
So, on my system (Blender 2.93.4), I will never get UDIM images with “Change Resolution”. Just “Single Image” files.
-
repo owner Oh, you mean that you change resolution after you make udim materials. Never tried that, but I agree that it would be useful. The previous fix change the naming convension so you can make udim materials with the lower-resolution textures already in place.
-
repo owner Now you should be able to resize textures and change resolution with udim materials too.
-
reporter Works great now. Really helpful to reduce the texture size for background meshes.
-
reporter - changed status to resolved
- Log in to comment
Implemented in last commit.