Announcement

Collapse
No announcement yet.

Looking for a script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for a script

    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.

    Anyone recall that?
    "It's the rebels sir....They're here..."

  • #2
    there is a new tool in max 9 to do that...I think it is bitmap proxy.
    show me the money!!

    Comment


    • #3
      That works to a degree but I want to generate a list or identify textures in order to change them rather than globally scale them down.
      "It's the rebels sir....They're here..."

      Comment


      • #4
        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)

        -Colin
        Colin Senner

        Comment


        • #5
          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.
          "It's the rebels sir....They're here..."

          Comment


          • #6
            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.
            - Geoff

            Comment


            • #7
              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

              Code:
              (
              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
              Dave Buchhofer. // Vsaiwrk

              Comment


              • #8
                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.

                Thanks for the input.
                "It's the rebels sir....They're here..."

                Comment


                • #9
                  Update: forgot to post this last night

                  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!

                  http://www.colinsenner.com/personal/...eBitmaps1.3.ms

                  code below

                  Code:
                  -- FindLargeBitmaps by Colin Senner for Arnold Imaging LLC c2007 
                  -- v1.3
                  
                  -- Close previous instances of the script if running
                  if rf != undefined then closeRolloutFloater rf
                  
                  
                  -- Rollouts
                  global rf, rlt_Info, rlt_Main
                  
                  -- Functions
                  global openRolloutNextTo, isValidNumber, closeRollout
                  global sizeSort, dimSort
                  
                  -- Variables
                  global whichSort = 0		-- 1 = dimensional sort, 2 = Size sort
                  global listItems = #()
                  global listItemsDims = #()
                  global listItemsSize = #()
                  
                  fn closeRollout rlt = (	if rlt.open then destroyDialog rlt )
                  fn openRolloutNextTo sRlt dRlt thewidth theheight = (
                  	closeRollout dRlt
                  	if dRlt.open == false then (
                  		local theposx = rf.pos.x
                  		local theposy = rf.pos.y
                  		local thenewposx = (sRlt.width+27)+theposx
                  		createDialog dRlt width:thewidth height:theheight pos:[thenewposx,theposy]
                  	)	
                  )
                  
                  fn isValidNumber val = (
                  	if ((val as integer) == undefined) or ((val as integer) == undefined) then 
                  		return false
                  	return true	
                  )
                  
                  fn sizeSort = (
                  	for i = 1 to listItemsSize.count do (
                  		try ( 
                  			while listItemsSize&#91;i&#93; < listItemsSize&#91;i+1&#93; do &#40;
                  				swap listItemsSize&#91;i&#93; listItemsSize&#91;i+1&#93;
                  				swap listItems&#91;i&#93; listItems&#91;i+1&#93;
                  				swap listItemsDims&#91;i&#93; listItemsDims&#91;i+1&#93;
                  				i = i - 1
                  			&#41;
                  		&#41; catch &#40;&#41;
                  	&#41;	
                  &#41;
                  
                  fn dimSort = &#40;
                  	for i = 1 to listItemsDims.count do &#40;
                  		try &#40; 
                  			while listItemsDims&#91;i&#93;.x < listItemsDims&#91;i+1&#93;.x do &#40;
                  				swap listItemsDims&#91;i&#93; listItemsDims&#91;i+1&#93;
                  				swap listItems&#91;i&#93; listItems&#91;i+1&#93;
                  				swap listItemsSize&#91;i&#93; listItemsSize&#91;i+1&#93;
                  				
                  				i = i - 1
                  			&#41;
                  		&#41; catch &#40;&#41;
                  	&#41;		
                  &#41;
                  
                  rollout rlt_Info "Maps" &#40;
                  	listbox lst_maps "Maps matching your criteria" height&#58;20
                  	edittext edt_Info "path&#58; " width&#58;473
                  	
                  	on rlt_Info open do &#40;
                  		local toList = #&#40;&#41;
                  	
                  		if whichSort == 1 then &#40;			-- Dimensions
                  			for i = 1 to listItems.count do
                  				toList&#91;i&#93; = &#40;listItemsDims&#91;i&#93; as string&#41; + "   -   " + &#40;listItemsSize&#91;i&#93; as string&#41; + " KB   -  " + &#40;listItems&#91;i&#93;&#41;
                  		&#41;
                  		else if whichSort == 2 then &#40;		-- Size
                  			for i = 1 to listItems.count do
                  				toList&#91;i&#93; = &#40;listItemsSize&#91;i&#93; as string&#41; + " KB   -   " + &#40;listItemsDims&#91;i&#93; as string&#41; + "  -  " + &#40;listItems&#91;i&#93;&#41;
                  		&#41;
                  
                  		lst_maps.items = #&#40;&#41;		
                  		lst_maps.items = toList
                  		whichSort = 0
                  	&#41;
                  	
                  	on lst_maps selected arg do
                  		edt_Info.text = listItems&#91;arg&#93;
                  &#41;
                  
                  rollout rlt_Main "Find Large Bitmaps" &#40;
                  	group "Dimensions" &#40;
                  		label lbl_text1 "If greater than these dimensions"
                  		edittext edt_wDim "width&#58;  " fieldwidth&#58;40 text&#58;"0"
                  		label lbl_wPx "px" offset&#58;&#91;-8,-18&#93;
                  		edittext edt_hDim "height&#58; " fieldwidth&#58;40 text&#58;"0"
                  		label lbl_hPx "px" offset&#58;&#91;-8,-18&#93;
                  		button btn_dimFind "Find" offset&#58;&#91;50,-33&#93; width&#58;70
                  		label lbl_space1 ""
                  	&#41;
                  	group "File Size" &#40;
                  		label lbl_text2 "If larger than this filesize"
                  		edittext edt_size "" text&#58;"0" fieldwidth&#58;45 offset&#58;&#91;20,4&#93;
                  		label lbl_text_kb "kb" offset&#58;&#91;-15,-20&#93;
                  		button btn_sizeFind "Find" align&#58;#center offset&#58;&#91;50,-23&#93; width&#58;70
                  	&#41;
                  
                  	fn clearGlobalArrays = &#40;
                  		listItems = #&#40;&#41;
                  		listItemsDims = #&#40;&#41;
                  		listItemsSize = #&#40;&#41;
                  	&#41;
                  	
                  	fn getBitmaps = &#40;
                  		local bmaps = getClassInstances BitmapTexture
                  		local gbmaps = #&#40;&#41;
                  		
                  		gbmaps = for b in bmaps where &#40;doesFileExist b.filename&#41; collect b 	
                  		gbmaps
                  	&#41;
                  	
                  	fn getBitmapFilter sortType w h size = &#40;  -- if sortType = 1 then filter by Dimensions, if sortType = 2 then filter by Size
                  		local maps = getBitmaps&#40;&#41;
                  		clearGlobalArrays&#40;&#41;
                  		
                  		if sortType == 1 then &#40;			-- Dimensions		
                  			for i = 1 to maps.count where &#40;maps&#91;i&#93;.bitmap.width >= w&#41; and &#40;maps&#91;i&#93;.bitmap.height >= h&#41; do &#40;
                  				append listItems maps&#91;i&#93;.filename
                  				append listItemsDims &#40;point2 maps&#91;i&#93;.bitmap.width maps&#91;i&#93;.bitmap.height&#41;
                  				append listItemsSize &#40;&#40;getFileSize maps&#91;i&#93;.filename&#41;/1024&#41;
                  			&#41;
                  			dimSort&#40;&#41;	
                  			whichSort=1		
                  		&#41;
                  		else if sortType == 2 then &#40;		-- Filesize
                  			for i = 1 to maps.count where &#40;&#40;&#40;getFileSize maps&#91;i&#93;.filename&#41;/1024&#41; >= size&#41; do &#40;
                  				append listItems maps&#91;i&#93;.filename
                  				append listItemsDims &#40;point2 maps&#91;i&#93;.bitmap.width maps&#91;i&#93;.bitmap.height&#41;
                  				append listItemsSize &#40;&#40;getFileSize maps&#91;i&#93;.filename&#41;/1024&#41;
                  			&#41;
                  			sizeSort&#40;&#41; -- Sorts the arrays based on size of the bitmaps
                  			whichSort=2
                  		&#41;
                  	&#41;
                  		
                  	on btn_dimFind pressed do &#40;
                  		if &#40;isValidNumber edt_wDim.text&#41; and &#40;isValidNumber edt_hDim.text&#41; then &#40;
                  			local theWidth = &#40;edt_wDim.text as integer&#41;
                  			local theHeight = &#40;edt_hDim.text as integer&#41;
                  
                  			getBitmapFilter 1 theWidth theHeight 0
                  			openRolloutNextTo rlt_Main rlt_Info 500 315
                  		&#41;
                  	&#41;
                  	
                  	on btn_sizeFind pressed do &#40;
                  		if &#40;isValidNumber edt_size.text&#41; then 
                  			getBitmapFilter 2 0 0 &#40;edt_size.text as integer&#41;
                  
                  		openRolloutNextTo rlt_Main rlt_Info 500 315
                  	&#41;
                  
                  	on rlt_Main close do
                  		try &#40; destroyDialog rlt_Info &#41; catch &#40;&#41;
                  &#41;
                  
                  rf = newRolloutFloater "Find Large Bitmaps v1.3" 230 207
                  addRollout rlt_Main rf
                  Colin Senner

                  Comment


                  • #10
                    Very useful, thanks MoonDoggie!
                    Eric Boer
                    Dev

                    Comment


                    • #11
                      Very simple idea and seems to work perfectly. Great tool. Thanks.
                      www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

                      Comment


                      • #12
                        Originally posted by YoyoBoy
                        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.
                        This would be more useful if all your maps are in the same directory (ideally), sometimes that's not the case.
                        Colin Senner

                        Comment


                        • #13
                          Found a bug, please download v1.1, improved.
                          Colin Senner

                          Comment


                          • #14
                            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.
                            "It's the rebels sir....They're here..."

                            Comment


                            • #15
                              Really clever, well done mate.

                              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...

                              Lele
                              Lele
                              Trouble Stirrer in RnD @ Chaos
                              ----------------------
                              emanuele.lecchi@chaos.com

                              Disclaimer:
                              The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                              Comment

                              Working...
                              X