View Full Version : New Free Script ... SM Scene Optimizer

03 March 2005, 11:14 AM
Hi all ....

I'd written this script some time back and it should help u when working every heavy scenes with a lot of geometry .....

This script should be of good use to animators, lighting artist, environment modellers, shading guys,


1).Launching the optimizer makes your scene very light (for navigation purpose) in the viewports ...
What u see in the viewport is not what will be rendered.

2).After launching optimizer, u can interactively put on or off the optimize effect on selection of objects.... using the "OPT ON" and "OPT OFF" buttons.

3).u can also set the level of optimization required on the whole scene or on selection of objects using the vertical slider .... taking the slider up means more optimization.....

4).The button "Kill Optimizer" will remove all optimizations from the entire scene (or selected objects if your have clicked on the "sel" radio button....

5)."MS ON" and "MS OFF" with "scene" radio selected puts on or off Meshsmooth for all objects in the scene which have a meshsmooth applied ..... if "sel" radio is activated, the same works on selected objects only

6).When u render the scene, it shows u actual geometry, not optimized stuff.....

7).U can use the "launch optimizer" in one session of max, save the scene and use
"kill optimizer" in another session of max

8).The button exclude objects is not yet implemented .....

example Usage:

Suppose u r working on a forest shot with tons of geometry in trees, leaves , terrain, stones, etc, and a character running thro a path in the jungle:

# if u r an animator , u could click 'launch optimizer' to optimize the whole scene,
and then remove optimization on only the character u r animating, and
maybe also the path

# if u r lighting/shading the scene, u can keep the whole scene optimized and yet see render
results which are un optimized....

hope it helps someone ....

03 March 2005, 12:01 PM
It seems very nice but i didn't try it on a big scene.
How about Xrefs ? Does the script handles them ?

And maybe you could implement an option to show/hide the materials which have a big impact on real time display.
In attachement is a nice script from Ken Turner (thanks to him) that do this very well and handles multimaterial.

Any way thanks for your script.

03 March 2005, 12:22 PM
Haven't tried it yet but great idea! I'll give it a try :)

03 March 2005, 01:54 PM
u r welcome, namoi ....
it should handle xref objects, but definitely not xref scenes .....

and thats a good suggestion about putting on/off the textures ......
i think i had written something similar for a different purpose in a separate script ..... i'll try to incorporate that one into the optimizer.

i hope to upload a revised version soon....


03 March 2005, 07:46 PM
Wow - works a treat! Good stuff. What versions does it support?

03 March 2005, 07:41 AM
I have uploaded a new version of Scene Optimizer...
Clicking on "Launch Optimizer" button, now also puts off all textures seen in the viewport....
U can also use this tool to interactively put On or OFF textures of all objects in scene or only for selected objects....

Thank u namoi for your inputs....

03 March 2005, 10:31 AM
You're welcome.

But about this feature, i'm trying to upgrade it.
For now, all the scripts i've seen only hide/show the textures for the standard mat and the first level of a multimaterial. It could be great it to show/hide the textures for selected objects like the "activate/deactivate all maps" function build in max. Unlikely this function doesn't seem to be exposed in maxscript and if it was it would be maybe difficult to make it work for only selected objects.

For en example of the limitation of the show/hide script, try to apply a composite mat with a standard mat contening a bitmap texture and assign it to a face of a mesh.
Now assign to another face a multimaterial with a standard mat inside with again a bitmaptexture.
Try to show/hide the mat. You'll see that only the standrd mat in the multimat shows or hides. The standard mat in the composite mat is ignored. But if you try to "activate all maps" in the view menu, all the textures "magically" appear.

To solve maybe this problem, i found an extension (named fooFunctions (maxR5) and embeded in the Wad-O-MXS-Wads! v1.02 pack) on that expose some functions to deal with textures and materials:

Takes an object using a multi/SO material, and removes any unused sub-materials.

Get all the submaterials of the passed material.

Get all the standard submaterials of the passed material.

Get all the materials and submaterials applied to the passed object.

Get all the standard materials and submaterials applied to the passed object.

Get all the subtextures of the passed material or texture.

Get all the bitmap subtextures of the passed material or texture.

Get which material IDs are used in an object.

Takes a multi/SO material, and remove any duplicate sub-materials.

If someone else want to put a little time on this, it could be usefull for everyone.

A little more about those extensions. In order to make them work you need the avguard extensions for your max version. In the scriptspot pack, the one for max 7 is missing. I post it here. Put it in the stdplugs directory, and DON'T FORGET to rename it avg_dlx.dlx.
More: one of the function the mzp call doesn't work on max 7 (maybe 6 too), so you have to decompress the mzp (rename foofunctions.mzp to, open the and remove the line calling the (append fileinarray ""). I don't think this function as an impact for the material ones. Recompress the mzp and launch it.

03 March 2005, 05:52 PM
Again me.

I tried to do the "advanced" show/hide scripts. Now it seems to work ok. I just see some strange behavior with composite materials time to times (maybe other, don't know).

But anyway, this time it's a lot better. I put the functions in attachement for everybody.
In fact, we don't need no extensions at all, it's just a couple of function from John Burnett which were in the extension pack (it explains my misunderstanding).
So in the txt file, you'll find some functions used by 4 buttons. Two are to hide/show materials from a selection of objects and 2 to show/hide the material located in the current Material Editor Slot.

Hope this help

06 June 2005, 10:27 PM


06 June 2005, 07:15 AM

First of all, thanks for this script!
I 've been testing it and i have found that it works pretty fast when optimizing, but it is terrible slow killing the optimizer! Also, i had to re-run the script because an error i get when using the MS OFF button. I think that this should be changed from meshmooth to turbosmooth (or both) :)
I have been testing this with an scene im working on (you can see the wip here: to see of what im talking about) The problem is that the Optimizer does a good job with the face, skull, body, and in general with big objects, but it does not touch the rings of the chainmail. Why this could be? those are simple torus...

I hope it can help to improve that great script!

06 June 2005, 11:24 AM
yes, i have to add the turbosmooth thing ....
about the error that you get, could you please copy paste it for me to see? better would be if you can mail me a max file with maybe only the problem objects ...
i really appreciate the error report ..... i hope i can fix the problem.
about the chain mail torus objects, try to move the optimize slider up. You could do that to the whole scene or by selecting only the chainmail objects and the "selected" radio button
sorry for getting back to you so late.

06 June 2005, 03:25 PM
Hi Jhotun ....
Thanks to you, I could find a bug in the script which caused the slow down when killing the optimizer....
Here is the faster version:

Thats a great model u have there

06 June 2005, 11:14 AM
hey aaaaCHoooo, sorry for the delay :) I've been very busy with the image of the wip and i forgot this thread :)
I'll test the script this afternoon and ill post my results later. Thanks a lot for your interest!

06 June 2005, 11:30 AM

I installed the script, opened the scene and clicked on MS OFF. Then the message of the image appeared. This is the complete paste of the error line:

for obj in SceneGeometry do try (obj.modifiers[#MeshSmooth].enabledinViews = false) catch()

After that, it all dissapears and needs reset :P

Edit: Well, if i do not hit that ms off button it all works perfect :D Now it is very fast.Thanks!

06 June 2005, 08:33 PM

I installed the script, opened the scene and clicked on MS OFF. Then the message of the image appeared. This is the complete paste of the error line:

for obj in SceneGeometry do try (obj.modifiers[#MeshSmooth].enabledinViews = false) catch()

After that, it all dissapears and needs reset :P

Edit: Well, if i do not hit that ms off button it all works perfect :D Now it is very fast.Thanks!

ooops ! ... I should have mentioned this somewhere ....
The buttons Opti ON/OFF, MS ON/OFF and Tex ON/OFF will work only after you have clicked Launch Optimizer, atleast once ...... Anyways, I have included some error catching in the script, so it should not be an error anymore ..... I've replaced the scripts Ver 1.6 and 1.5, just download it again, and things should go right.

CGTalk Moderation
06 June 2005, 08:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.