by jalley » Wed Sep 06, 2017 4:26 pm
jalley
Wed Sep 06, 2017 4:26 pm
I am rather new to Unity/Octane but I manage to write down an initial Editor script that dumps Octane renders using Octane.Renderer C# API. The main idea was to keep a Unity CoRoutine launched from Update() waiting for Octane to finish the render in the PBR Viewport for as long as needed to let Octane Renderer finish the render with the desired #spp (samples per pixel).
This idea however comes with an inner drawback, as launching one of this coroutine per frame, causes an overhead in the number of coroutines used, as many are waiting for the same frame to finish, however my understanding is that most of them should return from the yield instruction when a render is ready and do not need to do anything else. I have tried WaitUntil yield construction but results I obtained were somehow unexpected.
So, the proposed solution worked fine, and I have empirically observered that when rendering with Time.captureFramerate of Unity, Octane manages to achieve one third of the desired frames, so e.g. you need to set 90 in order to get 30 fps in Octane. I have tried this even varying the #spp obtaining with the same ratio. This seemed to work fine until ... I had found another problem.
The main problem I still have is that when the scene contains heavy geometry/animations, the Octane PBR Viewport remains with the "Compiling Scene ..." message even if Time.timeScale is set to zero and Unity remains paused in the same state with no changes at all happening in the scene. This is quite frustrating as the script keeps waiting and Unity keeps blocked forever.
My Coroutine Pseudocode:
IEnumerator WaitForOctaneRender()
{
while ( Octane.Renderer.IsCompiling
|| ! Octane.Renderer.GetLatestRenderStatistics().samplesPerPixel.Equals(m_MaxSamplesPerPixel)
|| ! Octane.Renderer.GetLatestRenderStatistics().state.Equals(Octane.RenderState.RSTATE_FINISHED))
{
captured = false;
Time.timeScale = 0;
yield return 0;
}
// Capture frame
if (!captured) { Octane.Renderer.SaveImage(...); Time.timeScale = 1; captured = true; }
yield break;
}
Any suggestion/help from the Octane Rendering team or anybody else facing similar issues? Thank you.