Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheSHEEEP · Dec 05, 2011 at 10:50 PM · animationvideospeedframerate

Allow Unity to render as fast as possible?

Hey there,

I hope I can make my issue clear, it's not that easy to get into :)

What I am trying to do is rendering a live video from the running application, as fast as possible (and then do other stuff with that video, but that is of no concern here). The video capturing itself is already working (I have written a dll using ffmpeg).

Now the problem is the "as fast as possible".

Normally, when you load in - for example - an animated character, you want its 1 second animation to play in 1 second, no matter how many frames that is on the clients platform.

I want this "scaling" to be gone. If the animation has 30 frames with a setup of 30 frames per second (not sure if Maya saves the desired fps), I want those 30 frames finished in 30 unity frames, and if that only takes 0.2 seconds for the engine and looks awkward as hell, then this is exactly what I want. Think of the old DOS games that had no time scaling and ran ridiculously fast as PCs became faster. The DLL itself then scales 30 frames it gets from the engine to be one second in the output video. What counts is that the video is rendered as fast as possible, and that is not possible if the engine slows itself down to appeal to the eye.

I tried setting the Application.targetFrameRate to -1, but that did not remove the animation scaling. My guess (and hope) is that unity uses some deltaTime variable in everything it does internal. And I want that deltaTime to be 1, or 0, or whatever disables it. Unfortunately, I couldn't find anything.

I am aware that this is completely irrelevant for 99% of all Unity development cases, so it may be that it simply is not possible that easy. Would this change maybe require source code access to Unity?

PS: I already have this running in another engine, and all it took there was to simply not apply any deltaTime, but the company I work for wants to switch to a better engine. And me too :D

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Dec 05, 2011 at 11:28 PM

Ok, as you said it's against everything people would expect from an engine :D. You can't simply "turn off" deltaTime. Animations don't have frames (well in a lot animation tools the timeline is split into frames but that's irrelevant), they have keyframes! Keyframes usually aren't at fix timesteps. They are placed at important spots in a movement.

However if you want to play an animation at a custom pseudo frame-rate you have to do it manually.

The easiest way would be to set the AnimationState.normalizedTime manually from 0 to 1 in the desired speed. A small example: If you have an animation that takes 1.5 sec and have 30 frames (in your animation software) you just need to increase the normalized time by 1/30 each visual frame. That way the animation gets sampled at fix positions along it's timeline.

You just need to enable the animationState and set it's weight to 1.0. Don't use Play, CrossFade or any similar functions in this case.

I'm still not sure why you need this. ;)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by TheSHEEEP · Dec 06, 2011 at 01:22 PM

Thanks for the answer, that was what I needed. Unfortunately, I would have to do this for everything... movement, videos in background, etc.. Speed all of that up. But at least that seems doable. Just not sure if we want to go with that much effort.

Another problem I have is that our animations are supposed to be in 30 fps. And I cannot get Unity to play faster than 70fps. This is at least more than double speed, but capturing the video reduces this by over 30 fps, so in the end we are capturing at around 30-40 fps, which is almost no gain.

As a comparison, the engine we currently use renders (and captures with the same plugin) at over 200 fps, in debug mode.

There is nothing but an animated character, 2 or 3 (unanimated) props and possibly a video playing in the background. This is nothing, which is why the engine can run that fast.

In Unity, only the animated character is there, and still there is 70fps at max. Quality settings have no impact here. I still have the feeling the negine is "holding back". Or is Unity really that slow? That would be bad.

Should I probably open a new question for this?

EDIT:

FPS problem is solved. Editor never goes fast than 70fps. Outside of the editor, I get around 1100 frames (160-170 while capturing), which is fine for the moment. Consider this one solved.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Dec 06, 2011 at 03:08 PM 0
Share

Good to hear ;) I don't know for what platform you develop (i guess standalone) but you might have a look at Application.targetFrameRate. Note the hint about vsync and webplayer ;)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Speed up video play 2 Answers

How to select an animation clip by index number? 7 Answers

Animation speed 4 Answers

Small video files or sprite sheet animations? 0 Answers

How to calculate the speed at which a rigidbody2d is actually moving ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges