[Closed] get maps aplied to modifiers
Is there any universal way to get all types of maps applied to all modifiers that may support maps?
If possible – without getclassInstances.
fn getMaps node = (
local maps = #()
for i=1 to node.modifiers.count do (
for p in getpropnames node.modifiers[i] do (
pp = (getproperty node.modifiers[i] p)
case of (
(classof pp == bitmap): append maps pp
(classof pp == bitmaptexture): append maps pp
(superclassof pp == texturemap): append maps pp
default:()
)
)
)
makeuniquearray maps
)
don’t know if it’s universal enough
Oh, thax!
the thing is that usedMaps <modifier> doesn’t give maps with missing files (correct me if I’m wrong).
I need to compare now serejah’s method with
enumeratefiles <modifier> AddMap
enumeratefiles <modifier> AddMap #missing
which method is faster for very big scenes.
(
--===================================usedMaps====================================
st = timestamp(); sh = heapfree
fn getMaps =
(
local maps = #()
for obj in geometry where obj.modifiers.count != 0 do
for i=1 to obj.modifiers.count do
append maps (usedMaps obj.modifiers[i])
makeuniquearray maps
maps
)
m = getMaps()
format "usedMaps <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s
--====================================getpropnames=======================================
st = timestamp(); sh = heapfree
fn getMaps =
(
local maps = #()
for obj in geometry where obj.modifiers.count != 0 do
for i=1 to obj.modifiers.count do
(
for p in getpropnames obj.modifiers[i] do
(
pp = (getproperty obj.modifiers[i] p)
case of
(
(classof pp == bitmap): append maps pp
(classof pp == bitmaptexture): append maps pp
(superclassof pp == texturemap): append maps pp
default:()
)
)
)
makeuniquearray maps
maps
)
m = getMaps()
format "getpropnames <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s.filename
--====================================EnumerateFiles=======================================
st = timestamp(); sh = heapfree
local mapfiles=#()
fn AddMap mapfile =
(
append mapfiles mapfile
)
fn getMaps =
(
mapfiles=#()
for obj in geometry where obj.modifiers.count != 0 do
for s in obj.modifiers do
(
enumeratefiles s AddMap
enumeratefiles s AddMap #missing
)
makeuniquearray mapfiles
mapfiles
)
m = getMaps()
format "enumeratefiles <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s
)
in one of my heaviest scenes I have such result:
usedMaps <modifier>:6122ms ram:897552L
getpropnames <modifier>:10895ms ram:27513360L
enumeratefiles <modifier>:23322ms ram:7120L
usedMaps is fastest, but unfortunatelly it doesn’t give missing maps.
But this is really slow for my needs. and here I still don’t scan maps from lights
In my case I have a lot of instances, and if I exclude instances, then I get such result:
(
--===================================usedMaps====================================
st = timestamp(); sh = heapfree
fn getMaps =
(
local maps = #()
local AllInstances=#()
for obj in geometry where obj.modifiers.count != 0 and (FindItem AllInstances obj)==0 do
(
for i=1 to obj.modifiers.count do
append maps (usedMaps obj.modifiers[i])
InstanceMgr.GetInstances obj &instances
join AllInstances instances
)
makeuniquearray maps
maps
)
m = getMaps()
format "usedMaps <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s
--====================================getpropnames=======================================
st = timestamp(); sh = heapfree
fn getMaps =
(
local maps = #()
local AllInstances=#()
for obj in geometry where obj.modifiers.count != 0 and (FindItem AllInstances obj)==0 do
(
for i=1 to obj.modifiers.count do
(
for p in getpropnames obj.modifiers[i] do
(
pp = (getproperty obj.modifiers[i] p)
case of
(
(classof pp == bitmap): append maps pp
(classof pp == bitmaptexture): append maps pp
(superclassof pp == texturemap): append maps pp
default:()
)
)
)
InstanceMgr.GetInstances obj &instances
join AllInstances instances
)
makeuniquearray maps
maps
)
m = getMaps()
format "getpropnames <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s.filename
--====================================EnumerateFiles=======================================
st = timestamp(); sh = heapfree
local mapfiles=#()
fn AddMap mapfile =
(
append mapfiles mapfile
)
fn getMaps =
(
mapfiles=#()
local AllInstances=#()
for obj in geometry where obj.modifiers.count != 0 and (FindItem AllInstances obj)==0 do
(
for s in obj.modifiers do
(
enumeratefiles s AddMap
enumeratefiles s AddMap #missing
)
InstanceMgr.GetInstances obj &instances
join AllInstances instances
)
makeuniquearray mapfiles
mapfiles
)
m = getMaps()
format "enumeratefiles <modifier>:%ms ram:%
" (timestamp()-st) (sh-heapfree)
--for s in m do print s
)
usedMaps <modifier>: 5788ms ram:118680L
getpropnames <modifier>: 2087ms ram:3187064L
enumeratefiles <modifier>: 1603ms ram:52408L
is it possible in Serejah’s method not to iterate through all propNames, somehow with
(isProperty map #filename)
in order to make things faster?
enumeratefiles <modifier>: 1603ms ram:52408L
it’s fast enough. the task doesn’t need ‘real-time’ solution.
the good thing is that you can ‘entertain’ your user by a simple progress bar during the search
with using of enumerateFiles you loosing the information where a texture was found (in case you want to replace it for example).
the best is to get the map and then to get the texture from it. But if this takes time, then it is enough to get only
the object
modifier name where the texture is applied
texture itself.
I get this object and modifiers name, no problem. the question is about speed.
prefferable
#maps also, but only if it is faster and lower memory if slowest then no need.
I think there are a lot of modifiers that do not support maps with textures, and a lot that support. why should I enumerate for those that do not have such features?
is there any way to check if a certain modifier has such option?