• 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
1
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
3

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 4 · 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 :)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

34 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

Related Questions

VSync won't disable 3 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to turn camera using LookAt() only along X and Y axis? 1 Answer

Make part of a camera viewport invisible/transparent 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges