I seem to remember seeing either a wish list or post of a script or need for a script that would locate or identify texture maps of a given size in a scene( byte or dimensions). Cant find anything in the forums about it so I may have been dreaming.
Great idea, it would be nice to at least have a good idea of the big textures used in the scene in case you accidentally forgot to resize it in photoshop, or convert it to jpeg.
I will see how difficult it would be to write one (if MXS has access to filesizes, then it’s absolutely possible and not difficult)
Thanks, it would be a tremendous help. We often run into scenes that
have to be re-rendered at hires or something whacky happens and
end up goung through every single material one at a time trying to
find efficiencies.
Something that would create a list or flag textures over a given btye
size and/or pixel dimension would be amazing.
In case you didn’t know, in Windows Explorer you can choose “Dimensions” as one of the columns in “details” view while listing files. Just right-click the columns and select “more…” at the bottom and check it off.
i’d started something like that ages ago.. let me see if i can find it and throw it out for anyone else to play with.
heres most of it.. though it was pretty ghetto because i just needed to find something in a huge file, so the only output is to the maxscript listener
(
r=sysinfo.getSystemMemoryInfo()
for i=2 to 7 do r[i] /= (1024*1024.)
format " mem use % percent free:total:\t %:% MB \n" r[1] r[3] r[2]
format " RAM in use: \t \t % MB \n" (r[2]-r[3])
format " Virtual Memory: \t \t% MB \n \n" (r[6]-r[7])
local mapfiles=#()
fn addmap mapfile =
(
local mapfileN=mapfile as name
local index=finditem mapfiles mapfileN
if index == 0 do append mapfiles mapfileN
)
enumeratefiles addmap
sort mapfiles
for mapfile in mapfiles do
(
novrmesh = (matchpattern (mapfile as string) pattern:"*vrmesh*" ignorecase:true)
if (novrmesh == false) do
(
try(bitmaptex = openbitmap mapfile)catch(print ("failed to open" + (mapfile as string)))
format ".. Map location: % \n" mapfile
format ".... is Width: % Height: % and % kb \n" bitmaptex.width bitmaptex.height (getFileSize mapfile)
)
)
)
And if i recall correctly, one of the problems with it as is, is that its running on mapfiles instead of bitmaptexture files.. so it would need to be changed in order to ignore silly things like procedural maps
Yeah, problem is not in explorer, its finding the files within MAX as the files are called from all over the place. At present I have to check each one individually, reveal in explorer, check it, change it if need be.
The idea being something that would identify the large texture maps automatically to keep from having to go through each material in the scene, which can be very many.
@dbuchoffer
That is a start will try it out, thanks so much, I unfortunately know very little about scripting but this might be the time to start learning.
v1.3 Now sorts your lists depending on what filtering (size or dimension) you choose
--------------------------------------------
Old:
I wrote this today. It will help us too. It’s very simple, but functional. If you have additional requests or helpful things I could add to it, please let me know!
That is amazing, thanks so so much! I can see only one more thing that would be handy, either the material name the material the map is associated with or the object(s) it is applied to, but that can be done looking throught the material editor too.
Thanks again, very cool.
One thing bugs me though: the discrepancy (sometimes huge) between the size of JPG textures on disk and when rendered.
As you know, a jpg on disk may be 10k, but once loaded and decompressed, may take up any size (imagine a perfectly white - ie. homogeneous-, 8k image, as an extreme).
I was wondering if it could be improved by somehow making it decompress the textures by loading them in a FB (which could also be invisible, making the process a lot faster), and doing a simple difference in system memory used from before and after decompression.
Maybe as an option…
i dont think you’d have to actually decompress/load the textures as the size in memory is a rather simple calc for Bitmaps : SizeX*SizeY*BitsPerChannel*NumberofChannels = Size in memory in bits.
Should be readable from the header and should be faster then actually loading the bitmap.
Regards,
Thorsten
Edit : Just saw that you are grabbing the texture dimensions anyways. so it’s easy to calc the size in memory.
At any rate, this script was written very fast, so optimizations etc can come later, and it can certainly be a community project if anyone has any ideas as the source script is plain english.
I love the idea about the size in memory. The formula Thorsten posted is relatively self-explanatory. I’d love to see it integrated into the script and UI. I will be happy to do it myself, once some questions are answered.
can you calculate other bitmapTexture formats the same way such as tifs, jpgs, etc.? Also let me know how it would be handled UI wise. A checkbox in the “Size” group that specifies if the maps are that big in memory?
It means your code is a hell of a lot cleaner and fool-proof than mine :lol:
Ideally, a checkbox that said “check uncompressed size”, and a pop-up box that warned that the process could take a long time and eat up some ram would be what I would put in, but i am no feng-shui follower when it comes to interface desing…
The fact is that Thorsten formula need YOU to take into account the formats (ie. a Tiff might be 8, 16 or 32 bits, headers may vary between image type flavours and so on and so forth), whereas in the case of a straight open into FB, you would eat up ram, but forget entirely the bother with the code.
A freescenebitmaps() after the FB has been closed and the bitmap flushed should ensure there is no ram pollution.