Our hardware– and doesn’t have to be new or expensive, viewport rendering, active shade (actually pretty useless thing, fortunately) make those methods obsolete, if ever it was really usable.
the method didn’t support gw.getviewportDIB()
or active shade
it’s just for rendering
The main drawback of frame-by-frame animation rendering is the lack of sound rendering capabilities. I don’t know why MZ needs to lighten the viewport (or camera view), but usually (at least in my experience) we need it in heavy cinematic scenes. But in this case, the sound is very important for the animation preview.
That is what we are doing all time when we open Max or any 3d app/editor – if we changing something.
Changing some animated object state to hidden can improve performance while making it invisible will not.
Animating visibility is not demanding – will not have much influence on viewport performance.
What I thought author problem here is (but really I don’t know if there’s any):
-If we have some obj. with demanding animation, and it will become invisible but still influence performance – while we animate other things .
I would suggest to stop that obj. animation at the time it become invisible and thought we exploring ways to do that.
There are more ways , but…
But who cares, he made the decision…
And he said in first post that he decided so
Here is another approach using .isHidden and node visibility, which should allow you to do hide/unhide objects y viewports and when rendering.
You need to be careful with the memory footprint.
(
VisibilityTrackDeff = attributes VisibilityTrack
(
parameters main rollout:params
(
rendering type:#integer ui:rb_render animatable:false default:1
visible type:#boolean ui:chk_visible animatable:true default:true
)
rollout params "Parameters"
(
groupbox gb "Rendering" width:136 height:58
radiobuttons rb_render "" pos:[22,24] labels:#("Enable in Viewport", "Enable in Renderer")
checkbox chk_visible "Visible" pos:[16,74] checked:true
on rb_render changed arg do
(
for j in (getclassinstances emptyModifier) where j.name == "Visibility" do j.rendering = arg
completeredraw()
)
on chk_visible changed arg do completeredraw()
)
on create do
(
visible.controller = boolean_float()
)
)
fn AddVisibilityModifier obj =
(
mdf = emptyModifier name:"Visibility"
custattributes.add mdf VisibilityTrackDeff
ctrl = float_script()
ctrl.addnode "obj" obj
ctrl.addobject "modifier" mdf
ctrl.addobject "visible" mdf.visible.controller
scr = "if (modifier.enabled == true) then" + "\n"
scr += "(" + "\n"
scr += " if (modifier.rendering == 1) then" + "\n"
scr += " (" + "\n"
scr += " obj.ishidden = visible.value == 0" + "\n"
scr += " 1.0" + "\n"
scr += " )else(" + "\n"
scr += " obj.ishidden = false" + "\n"
scr += " visible.value" + "\n"
scr += " )" + "\n"
scr += ")else(" + "\n"
scr += " obj.ishidden = false" + "\n"
scr += " 1.0" + "\n"
scr +=")"
ctrl.setexpression scr
obj.visibility = on
obj.visibility.controller = ctrl
addmodifier obj mdf
return mdf
)
/* Test Scene -------------------- */
delete objects
obj = teapot segs:64
AddVisibilityModifier obj
with animate on
(
for j = 1 to 100 by 5 do
(
at time j obj.modifiers[1].visible = (random 1 100 < 50)
)
)
)
Additionally, you could also use the node’s .boxmode instead of the .ishidden property, which would solve many issues.
This is same approach with scripted animation plugin, which works in max 2019 and above:
plugin FloatController IsHiddenController
name:"IsHidden Controller"
usePBValidity:false
classID:#(0xc1dbcd7, 0x70ecb08b)
(
local getting = false
parameters pblock rollout:params
(
valueController type:#maxobject subAnim:true
ownerMonitor type:#maxobject
)
rollout params "FloatController Test Parameters"
(
Spinner offset_value "Offset Value:" range:[0, 1e9, 40]
)
on getValue do
(
val = if valueController.value == 0 then 0 else 1
if classof ownerMonitor == NodeMonitor and isvalidnode (owner = ownerMonitor.node) and getting == false do
(
getting = true
owner.isnodehidden = if val == 0 then true else false
getting = false
)
val
)
on setValue val relVal commit do
(
val = if val == 0 then 0 else 1
SetControllerValue valueController val commit #absolute
)
on create do
(
valueController = NewDefaultFloatController()
isLeaf=true
)
)
delete objects
obj = teapot isselected:true
obj.visibility = cnt = IsHiddenController()
cnt.isKeyable = true
cnt.isleaf = false
cnt.ownerMonitor = nodemonitor node:obj
with animate on
(
at time 50 obj.visibility.controller.value = 0
)
I don’t get any error from Max 2014 to 2021, however hiding/unhiding the nodes this way may lead to instability.
I tried animating 1500 objects in viewport and rendering without problems.
Doesn’t even the provided sample scene run or did you do something different?
I don’t get the error anymore today, anyway this is great solution! I just don’t know what “Rendering” radio button does?