Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation support for 'visibility' #1314

Closed
calrk opened this issue Apr 10, 2018 · 12 comments
Closed

Animation support for 'visibility' #1314

calrk opened this issue Apr 10, 2018 · 12 comments

Comments

@calrk
Copy link

calrk commented Apr 10, 2018

I've been working with some models that use the visibility flag in their animations to show/hide meshes within the object. These models have been made in Maya, exported as fbx and tested in Unity with the flag working. This can be set as shown below from Maya:
image

I read the specification for the animation and it says The path may be "translation", "rotation" or "scale"...

I was wondering if it also supported the visibility property or if there were any plans to support it in future?

@donmccurdy
Copy link
Contributor

Currently visibility animation cannot be stored in glTF, although you could hack it with discrete/step animations of position or scale. Proper visibility animation would seem like a reasonable addition through #1301, but that will likely take some time.

@calrk
Copy link
Author

calrk commented Apr 10, 2018

Yeah I've suggested using the position or scale, so will enforce that the models follow that.

Thanks.

@calrk calrk closed this as completed Apr 10, 2018
@ctedin
Copy link

ctedin commented Nov 4, 2020

Visibility parameter control would be great. Scaling works pretty well though, in a pinch.

@spiraloid
Copy link

spiraloid commented Jan 5, 2021

I have a modular asset with lots of parts that need to be toggled on or off. showing them all at once, even scaled to 0.001 would overflow the polycount of the scene. is there a workable alternative?

@emackey
Copy link
Member

emackey commented Jan 5, 2021

There's no formal extension proposal for visibility yet (EDIT: Well there is #1790 but I can't tell if it has any momentum).

One option is to have the renderer check for scale being non-zero before rendering each node, and skip rendering of any nodes (and their children) when zero scale is encountered. Child nodes cannot produce any meaningful result at any scale when a parent is zero scale, so may also be skipped.

It seems likely that any future visibility extension would incur the almost same performance cost, adding a test per node at render time. Perhaps a Boolean test would be marginally faster than three scale axes floating-point tests, but would come at the expense of new code and mechanisms built for the purpose of animating a Boolean value over time. It seems difficult to justify a whole new category of animation import and export here, when one could get the same information by checking the scale of each node before rendering.

(Also note, glTF animations require the target node to avoid using a full transform matrix, and instead animate only the individual translate, rotate, and scale vectors as appropriate. This means that any animated scale will not be hidden inside a TRS matrix, and instead will be called out as a 3-component vector of scale by the animation. So it is safe to just look for those animations when implementing this optimization).

@donmccurdy
Copy link
Contributor

I've been thinking of this under a general bucket of material animation, so far. It could plausibly be handled by #1790 (defines variant "states", not timed keyframes), #1301 (arbitrary property animation), or #1889 (procedural graph-based material inputs).

@andybak
Copy link

andybak commented Aug 5, 2021

Can this issue be reopened? Or can it be closed with a proper reason (i.e. covered by another ticket, wontfix)?

Currently you need to read the entire conversation to understand what decisions have been made (and it's still not clear)

Personally I find the lack of visibility keyframes to be a strange omission and the workarounds are fairly unappealing.

@donmccurdy
Copy link
Contributor

FWIW I am now setting scale 0 <-> 1 with 'step' interpolation successfully in these cases.

For me (speaking personally) this lands in a category that should probably be included in some future glTF version, but which isn't independently important enough — since simple workarounds exist — to create a separate extension for it.

@andybak
Copy link

andybak commented Aug 5, 2021

FWIW I am now setting scale 0 <-> 1 with 'step' interpolation successfully in these cases.

How would that handle one obvious usecase that springs to mind - a sequence of meshes that are too heavy to be displayed all at once but are sequenced to play one after another?

I imagine the question is somewhat implementation dependent but generally speaking do 0 scale meshes get optimized away for would some part of the processing cost still apply?

@donmccurdy
Copy link
Contributor

I'd expect nearly all engines to implement frustum culling in some form. Certain implementations may not optimize away scale=0 perfectly, but in my tools that has been the case. Sequences of meshes are the main use case I'm aware of for this, as you mention.

@spiraloid
Copy link

I implemented moving the objects -100000 and it works fine. Thanks for the tips!

@mrBoogaloo
Copy link

I'll have to try the translation trick, scaling with stepped interpolation worked for glTF but broke when converting to USDZ. Fingers crossed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants