I’m working on a day night cycle and I’m wondering if it’s possible to disable the automatic realtime GI calculation and instead handle it manually through script?
The reason I’m asking is because I’m doing my day night cycle by rotating a directional light. And the calculations every frame caused by rotating this light every frame seems to be extremely expensive for the realtime GI, completely destroying my framerate unless I have a very low realtime GI resolution.
One option could be for me to only actually rotate the light when it has rotated more than say 5 degrees so that the GI recalculations happen a lot less often, but that doesn’t look good in my opinion.
I would much rather have the light rotate every frame so the shadows, specular etc. update smoothly, but have the GI be calculated every 5 degrees or similar.
Is this possible? Are there other ways for me to approach this?
But it seems to make no difference in performance or the look of my scene whether I set it to 0 or a million.
My framerate absolutely tanks in my day night cycle if the light is rotating every frame. It goes from 120fps to 40fps in my test scene. There are numerous time of day and day night cycle assets for Unity. Surely there’s a trick I’m missing, and I hope that trick isn’t just to avoid rotating the light every frame because that’s the one thing I want to keep.
I was hoping there was something like DynamicGI.updateMode = manual and then you could just throw something like DynamicGI.Update() into a coroutine and have complete manual control over when enlighten used resources.
Hi! Is this on 5.2.2p2 or an earlier build? 5.2.2p2 fixes Enlighten saturating the command buffer and stalling because of it. It will gives the biggest benefit in scenes with high rendering framerate.
I downloaded 5.2.2f1 now to check, but no difference.
I was talking to one of the developers behind PAMELA and he said that they were using the Time of Day asset from the asset store. Apparently it has a setting for specifying update intervals for the skydome, which I can only assume means that the sun only rotates in these intervals. I don’t want to spend 60 dollars just to check though.
He also said they were using a realtime GI resolution of 1. If I set my realtime GI resolution to 1 then my framerate doesn’t drop as much, it barely drops at all in fact. But 1 isn’t enough for my scene and the scene works beautifully with a setting of 5 or even higher as long as the sun isn’t rotating every frame.
I guess what I was hoping for or what I want is complete control over when the realtime GI eats my performance.
But I just realized this may be a bug or something I’m missing because according to both the stats display and the profiler I should have hundreds of fps, but according to the fps script I’ve been looking at I only have 40 fps. And most importantly it definitely feels like I only have 40 fps because it’s choppy as hell.
Here’s a screenshot. The fps script shows 42 fps in the inspector on the right.
using System;
using UnityEngine;
using UnityEngine.UI;
public class FPSCounter : MonoBehaviour {
const float fpsMeasurePeriod = 0.5f;
private int m_FpsAccumulator = 0;
private float m_FpsNextPeriod = 0;
private int m_CurrentFps;
const string display = "{0} FPS";
private Text m_GuiText;
private void Start() {
m_FpsNextPeriod = Time.realtimeSinceStartup + fpsMeasurePeriod;
m_GuiText = GetComponent<Text>();
}
private void Update() {
// measure average frames per second
m_FpsAccumulator++;
if (Time.realtimeSinceStartup > m_FpsNextPeriod) {
m_CurrentFps = (int) (m_FpsAccumulator/fpsMeasurePeriod);
m_FpsAccumulator = 0;
m_FpsNextPeriod += fpsMeasurePeriod;
m_GuiText.text = string.Format(display, m_CurrentFps);
}
}
}
I’m not sure where I found it, but like I said it feels like the framerate is really low so I’m sure Fraps would show similar framerates if I ran this in a standalone build.