Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
2
Question by Tiras69 · Sep 28, 2015 at 11:33 AM · c#cameraoptimizationframeratesettings

How to render severals cameras at differents Frame Rate ?

Hi everybody !
I work on a project that require to target a good fps amount. In my scene I have two Cameras: The main camera need to be rendered with a maximum fps whereas the second one is display on a renderTexture and can just be set to 30fps. I just want to know if it's possible and if it can really increase the overall fps in the game. I hope this is clear. Don't hesitate to ask questions.
Thank you.

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
1
Best Answer

Answer by MariuszKowalczyk · Sep 29, 2015 at 11:43 AM

Hello @Tiras69

The solution is to disable the camera component and use the Render() function at the rate you need.

This solution works, but for some reason it decreases the FPS for me, I am trying to find the reason at the moment.

Comment
Add comment · Show 2 · 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 MariuszKowalczyk · Sep 29, 2015 at 11:54 AM 0
Share

The solution for the fps drop for me was not to use the Render() function but just to disable and enable the camera at the desired rate.

avatar image Tiras69 · Sep 29, 2015 at 12:38 PM 0
Share

Hi thank you I tried something with the Render that look like this:

 private Camera cam;
 void Start () {
     cam = GetComponent<Camera> ();
     StartCoroutine (DelayedRendering ());
 }
 
 public IEnumerator DelayedRendering(){
     while (true) {
         cam.Render();
         yield return new WaitForSeconds(0.0466667f);
     }
 }

I'm quite happy with that because I increase my overall fps for about 5-10fps.
But I still need to optimize my project (but it's not in the Question field).

Can you tell me how you managed to activate and desactivate the camera component at a precise rate without manualy render the camera ?

Thank you I accept your reply.

avatar image
4

Answer by dongiorgi · Oct 21, 2016 at 12:54 PM

This might help

[RequireComponent(typeof(Camera))]

 public float FPS = 5f;
 public Camera renderCam;
 // Use this for initialization
 void Start () {
     InvokeRepeating ("Render", 0f, 1f / FPS);
 }
 void OnDestroy(){
     //CancelInvoke ();
 }

 void Render(){
     renderCam.enabled = true;

 }
 void OnPostRender(){
     renderCam.enabled = false;
 }
Comment
Add comment · Show 5 · 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 jiangzhen · Aug 18, 2017 at 01:45 PM 0
Share

WOW!! Save Battery! thank you!

avatar image Roywise · Jan 26, 2018 at 01:12 PM 0
Share

I tried the approach that Dongiorgi posted and it works great, improved performance by 5 to 10 frames per second. I've also tried to use renderCam.Render() to manually tell the camera to render but this did not yield any noticable improvements.

avatar image Zebbi · May 12, 2018 at 09:04 AM 0
Share

I tried attaching this to camera but the camera just says "No cameras rendering". Is there anything else I have to do to get this to work?

avatar image DanielleSisserman · Nov 11, 2018 at 09:07 AM 1
Share

thank you so much. now, completely off topic; i'm curious why you would cancel invoke in destroy? does the function go on the heap?

Thank you :)

avatar image FariAnderson · Oct 04, 2021 at 03:52 PM 0
Share

works great, my 300 fps game runs at 1800 fps now :)), tnx

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

35 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

VSync won't disable 3 Answers

Disabling Fog for 1 Camera? 2 Answers

3D Isometric Camera C# - Center on player? 2 Answers


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