Pausing time flow in editor viewport

Hello.

I’m working on a tool, that creates minimap in editor and saves it to file, so there won’t be a need to use real-time scene capture method. Since the map is quite big, it’s splitted into some number of tiles.

I’m done with that part, but because of a way I implemented it, it takes some tiny period of time between capturing image of each tile. The problem I’ve encountered is, that there are couple things that are animating in viewport such as water material, flags and such. And when I for example capture water on 2 tiles that are next to each other, the animation state differs and it’s quite visible and ugly.

My question is, if there is a way to pause a time flow in editor view (and then unpause it), so materials and other objects won’t animate in editor? I guess I could simply make copy of water material and remove anything related to time from there, but I’d prefer to find a better solution that would take care of all those objects at once instead of modifying duplicating every material.

Or maybe there’s an option in editor to just toggle such functionality. It seems like such feature could be needed for designers working with large worlds with lots of animated stuff.

What I’ve tried so far:

  • toggling ‘RealTime’ in viewport settings (works too good - it freezes my logic related to capturing minimap as well)
  • FViewport::SetGameRenderingEnabled(true); - found in Rama’s plugin (worked partially: rendring actually get frozen, but to me, not to scene capture component)
  • creating custom material function ‘GetTime’ that either returns actual Time multiplied by scalar value (to disable time, just put to 0) - this option however, is quite annoying as it requires me to recompile all shaders that use that function, it also forces me to replace all vanila UE4’s ‘Time’ nodes, with my custom one. This however, could potentially reduce performance (didn’t profile it tho) in final game.
  • FEditorViewportClient::SetRealTime - as expected, the same result as ‘RealTime’ option in viewport in the editor

An idea that I have so far, but didn’t test yet, would be to modify function in engine: HLSLMaterialTranslator::GameTime as it’s used by all time-related stuff in materials. If I’d return there some const value instead of actual time, it might work. But i’m not sure if it won’t break render target used by Scene Capture Component as well.

Any other ideas?

An update (and bump)…

I’ve tested a method with overriding HLSLMaterialTranslator::GameTime function. I’ve connected it with preprocesor + WITH_EDITOR macro and usage of TAutoConsoleVariable for toggling the feature.

It partially works. Despite the fact it actually is used by every (i’ve found so far) time-related node in materials, it’s used only for compilation purposes. So I still have to recompile all materials I want to freeze. :[

Anyone got other idea to solve this issue?

Okay, someone helped me to solve achieve this.

I basically used the same solution as the one with HLSLMaterialTranslator, but instead of modifying compiler, I changed the way renderer passes time related parameters to shaders.

SceneRenderer.cpp, line: around 900. Lines I played with:

FrameUniformShaderParameters.GameTime = Family->CurrentWorldTime;
FrameUniformShaderParameters.RealTime = Family->CurrentRealTime;