Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Animate color

8 REPLIES 8
Reply
Message 1 of 9
FRFR1426
641 Views, 8 Replies

Animate color

Can someone explain me why this works:

 

resetMaxFile()
b = box()
b.material = StandardMaterial()
animate on (
    at time 0 b.material.diffuseColor = red
    at time 100 b.material.diffuseColor = blue
)

 But this does not work:

 

resetMaxFile()
b = box()
b.material = Autodesk_Material()
animate on (
    at time 0 b.material.Generic_Color = red
    at time 100 b.material.Generic_Color = blue
)

 Thanks in advance

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
8 REPLIES 8
Message 2 of 9
blakestone
in reply to: FRFR1426

There is nothing wrong with your script, it seems that it fails to animate in the viewport when Materials are set to Standard Display with Maps. If you switch this to Hardware Display with Maps it seems to work fine. I am not 100% sure but maybe the Autodesk Generic Materials use DirectX or something like this!? 

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
Message 3 of 9
Steve_Curley
in reply to: blakestone

It's worse than that. I ran the script and unsurprisingly it failed. So, I did each step manually including the animation of the color (with autokey) - and it worked. There are differences between the two materials - a standard material color is a point3, the AD material color is a point4 (floating point RGBA).

I wonder if those have the same issues as Vertices - they need to be initialised to allow vertex animation (which happens automatically through the UI but not through a script). Pure guesswork - just tossing ideas about 😉

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 4 of 9
FRFR1426
in reply to: FRFR1426

If I add a third color, the cube turns green on image 100.

 

resetMaxFile()
b = box()
b.material = Autodesk_Material()
animate on (
    at time 0 b.material.Generic_Color = red
    at time 50 b.material.Generic_Color = green	
    at time 100 b.material.Generic_Color = blue
)

It is as if there was a shift. The green is only applied at time 100 instead of time 50. And the blue never appears.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 5 of 9
FRFR1426
in reply to: FRFR1426

If I duplicate the lines, it is working:

resetMaxFile()
b = box()
b.material = Autodesk_Material() 
animate on (
  at time 0 b.material.Generic_Color = red
  at time 50 b.material.Generic_Color = green
  at time 50 b.material.Generic_Color = green 
  at time 100 b.material.Generic_Color = blue
  at time 100 b.material.Generic_Color = blue
)

It should be possible to do better

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 6 of 9
Swordslayer
in reply to: FRFR1426

Not at max now but did you try assigning the controller directly?

 

resetMaxFile()
b = box material:(Autodesk_Material())
ctrl = Bezier_Point3()
(addNewKey ctrl.keys 0).value = red as point4
(addNewKey ctrl.keys 100).value = blue as point4
clearControllerNewFlag ctrl
b.material.Generic_Color.controller = ctrl

 

 

Message 7 of 9
FRFR1426
in reply to: Swordslayer

The controller type Bezier_Point3 is not compatible with the property Generic_Color. I've replaced it with a Bezier_Point4, but it still not works.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 8 of 9
Swordslayer
in reply to: FRFR1426

Okay, this is weird, when you change it to bezier_point4, run the script, pick the color to see it in material editor and move the timeslider, what do you see? On my machine it changes colors (and works in render too) but doesn't update color in viewport unless Show Realistic Material in Viewport is turned on (doesn't work with Show Shaded Material in Viewport either).

 

Forgot to add, in Track View the curves look perfectly alright, too.

Message 9 of 9
kevinvandecar
in reply to: FRFR1426

I also can reproduce this behavior. Interesting thing I see is like others said, if I create the Autodesk Material manually and key it, it works fine. But even then, if I save the scene and then restart 3ds Max and reload it, the viewport animation is often lost again on my system (but not always). The compact material editor, and also the render output is correctly animated in all cases (I think), but the viewport is not working well to display the animated color.

 

Another test I made was after reloading the scene, and manually creating a second material, it again worked on the maul one. But the one from the previous session sometimes does not animate for me in the viewport. Switching to the realistic viewport with maps appears to solve it again for the current session.

 

I also tested different viewport drivers. In the legacy OpenGL driver the same behavior seems like.

 

So, I believe this is related to the viewport somehow, but cannot see much more related. I also tested some other animated parameters of the Autodesk Material (Generic) and it see similar problems. For example, the "Image Fade" (Generic_Image_Fade property), also does not update in teh viewport until the realistic with maps is enabled.

 

I will ask engineering about, but before I do does anyone have anything else to add?

thanks, kevin


Kevin Vandecar
Developer Technical Services
Autodesk Developer Network



Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report