PDA

View Full Version : What is faster? Change diffuseColor or wireColor?


Eugenio
04-23-2008, 06:25 PM
Hi! I would like to know the faster method for changing the color of objects dynamically. Say, for example, bones when stretched turn to red, or, as in my case, lots of face controls that change their colors when not in it's default position.

Another question is what is the best method for doing this? I mean, actually I'm changing the wirecolor property through a script in a dummy object. But if I put a standardMaterial on each controller object and use a script controller for the diffuseColor, would that be any better (in regards to speed) than the way I did?

Regards,

Jr.

Bobo
04-23-2008, 06:33 PM
Hi! I would like to know the faster method for changing the color of objects dynamically. Say, for example, bones when stretched turn to red, or, as in my case, lots of face controls that change their colors when not in it's default position.

Another question is what is the best method for doing this? I mean, actually I'm changing the wirecolor property through a script in a dummy object. But if I put a standardMaterial on each controller object and use a script controller for the diffuseColor, would that be any better (in regards to speed) than the way I did?

Regards,

Jr.

Changing the .materia.diffuse is about 3 times faster.
For 100,000 iterations in Max 9, assigning a random color to the .material.diffuse in a Standard material takes 4297ms on my machine, while changing the .wirecolor takes 14000 ms.

Assigning the SAME color to the .wirecolor 100,000 times though is faster because Max checks whether the color is already set and does not update if the same color is assigned.

In Max 2008, I get the same times for .diffuse, but 10000 ms for .wirecolor, so it is slightly faster due to some object update optimizations.

Changing .wirecolor has lots of caveats because, as discussed in other threads, Max considers the .wirecolor NON-renderable and it would not update it when rendering.
Materials are generally considered animatable, but if the script controlling the color is in a non-renderable dummy, it might also refuse to update during rendering unless Max is informed that some renderable object depends on that dummy to force its update.
The best way to deal with rendering is to place the control in an object that is actually being rendered to ensure its controllers will be updated before each frame is rendered.

Eugenio
04-24-2008, 01:49 PM
Thanks a lot for the answer Bobo! Actually you have answered more than I asked! :thumbsup:

But I have another question, in my case here if we have about 5 characters in the same scene, it will have around 200 controls that change their colors just as a feedback showing that they were changed (so the rendering problem is not the case here).

So, if I want to change the diffuse color of the material, I must first to assign a material for each control, and then I will have more 200 materials in the scene. This will not make Max slower? Can I hide them for showing in ME? The material can't be an instance because if a controller change, all the others will change too.

It seems that changing wireColor is almost as slow as assign/reassign a material.

And thanks once more for the rendering advice! Very important information... ;)

Regards,

Jr.

Bobo
04-24-2008, 06:47 PM
Assigning (esp. REassigning) materials is slow. If the material is assigned once and then only the diffuse color is changed, then the material approach will be faster. In fact, Max 2008 and higher prefer objects with materials when redrawing the viewports. If you have to add and remove the material each time a color changes, that would be VERY slow and using the .wirecolor would be better.
Try it and see...

CGTalk Moderation
04-24-2008, 06:47 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.