Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
MichaelSchenck's avatar
MichaelSchenck
Honored Guest
12 years ago

Scale adjuster to help maintain framerate

I have been playing with adjusting the scale of the the render target to maintain frame rate and thought others would find the script helpful. This was discussed in a GDC talk (at about 49 min in) and is working in the Unity integration.

I did have to change the OVRCamera script to make the ScaleRenderTarget work properly. I am not sure if this is mistake or an incomplete implementation that I am hacking. Anyway, first you need to adjust these two lines in OVRCamera.cs


NeedsSetTexture = NeedsSetTexture || ((CameraController.ScaleRenderTarget != OldScale) || (Screen.fullScreen != wasFullScreen) || OVR_UnityGetModeChange());

to

NeedsSetTexture = NeedsSetTexture || ((Screen.fullScreen != wasFullScreen) || OVR_UnityGetModeChange());

and

OVR_SetTexture(EyeId, CameraTexture[EyeId].GetNativeTexturePtr(), CameraController.ScaleRenderTarget);

to

OVR_SetTexture(EyeId, CameraTexture[EyeId].GetNativeTexturePtr(), 1.0f);


After that just download the scale adjuster and add it as another script on your OVRCameraController in your instance in the scene (this is under the OVRPlayerController with the standard prefab) .

It doesn't work very well for me when running in the editor since it is just a huge judder fest running at 60 fps. When running builds however I get good results on some of my scenes that have more complex areas or certain vantage points where the framerate will drop down below 75fps. This would usually cause all kinds of judder and motion blur would kick in as the low persistence isn't working. Now, everything stays solid and the view gets slightly blurry in these cases. I now have a solid experience throughout the scene and have a solid framerate which makes everything more comfortable.

With my testing getting below a scale of 0.75 starts to get too blurry and becomes uncomfortable. I limit the scale to 0.5. If the performance is so bad and it needs to go below this then the quality level needs to change. I am thinking of incorporating a quality level adjuster into this so that if there is enough time below 0.75 or it is hitting up against 0.5 then the Unity quality level will be bumped down a notch. I don't think that it would make sense to ever adjust it back up. Someone could set what they want/think their system can handle and then it will be adjusted down as they start to play.

I am sure there are better ways to drive the adjustments than the simple approach I made. Please try it out and post any improvements you make. Happy world building!

6 Replies

Replies have been turned off for this discussion
  • That's really cool. So basically it reduces the resolution and upscales on demand when needed?
  • Yes, that is what happens in the SDK when reducing the render target scale value. I am attempting to use it to keep the frame rate solid, although my approach to measure frame rate and adjust this value hasn't worked out very well as a feedback loop. I have been playing with some other ways to do this but nothing has worked as effectively as I want it to. Hoping others may share a better technique. ;)
  • Anonymous's avatar
    Anonymous
    It creates a strange flicker when we use it. But we also use a 4 camera setup
  • Thanks for posting this I'll be sure to give it a try as soon as I have time!
  • "MichaelSchenck" wrote:
    I am attempting to use it to keep the frame rate solid, although my approach to measure frame rate and adjust this value hasn't worked out very well as a feedback loop. I have been playing with some other ways to do this but nothing has worked as effectively as I want it to. Hoping others may share a better technique.

    Have you tried a hysteresis bound? Basically, you could use two different, overlapping thresholds for rising and falling frame rates to avoid rapid oscillation between scaling up and down.
  • Great idea. I was thinking about this this morning and I'm glad someone is already doing it. I would think a drop in scene detail is much less jarring than scene studder in VR.