Is it possible to control the resolution/quality of a textured object through a python script (preferably without having to have three seperate textures of the same thing)…
My reason for asking this is pretty simple… I wanted an option in my game for texture quality so a higher range of PCs could run my game. But as I began to take my idea further I began to realize that the only way I could think of pulling that off was to create 3 of the same texture at different resolutions (which eats up game file size)…
If someone has a script to accomplish this or a better method, please share…
gill
Any one know how to do this?
gill
AFAIK I can do that. you need to spend game precious space with the low res textures. If procedural textures were possible in real time, then you could mes with the scale…
Maybe you can distribute the texture with the biggest size, and at the first run of the game, using a program(i’m sure there is at least a small freeware that can do this) distributed with the game resize them and give them specific names.
I am currently Coding a tiny program to do just this. I will post it when its finished!
Ex.
Great, would very thankful if you shared!
Thanks to everyone else for suggestions!
gill
Okay finished it. Now let me try to explain.
I wrote this as an external script using python 2.6, if you really wanted to you could run this in blender with little change to the script.
Here is what the script does.
It takes Full Quality Textures from Folder 1, downsizes them and copies them to Folder 2. Folder 1’s Textures Never change, they are just used for reference.
The game will then access the texture in Folder 2, that way you can change the quality of those textures, and then reload the game and the new updated textures will be reloaded into the game.
Hope this makes sense.
Ex.
EDIT: uploaded an informative pic - http://www.********.org/pic/5686
And maybe I should actually post the script. :rolleyes:
from PIL import Image
print ('Start')
import os
import sys
path = sys.path[0] + '\Texture Before'
path2 = sys.path[0] + '\Texture After'
print (path)
settings = 'Texture Settings.txt'
set = open(settings, 'r')
setR = set.read()
setR = int(setR)
print setR
dirList=os.listdir(path)
for fname in dirList:
#print fname
if '.jpg' in fname:
print fname
FileName = path + '/' + fname
image = Image.open(FileName)
FM = image.format
size = image.size
s1 = size[0]
s2 = size[1]
print (FM)
print (size)
# Low
if setR == 1:
width = s1/4
height = s2/4
# Mid
elif setR == 2:
width = s1/2
height = s1/2
# High
elif setR == 3:
width = s1
height = s2
im2 = image.resize((width, height), Image.NEAREST)
ext = '.' + FM
im2.save(path2+'/'+"TTT" + ext)
print('Done')