Update Reflection Capture on Runtime

Heya, I am crossposting this into the ArchViz Subforum in hopes that some of you have experienced the same problem and have found a way around it!


Hello,
now that i solved my UMG / Material Change >problem<](UMG controlling a Blueprint - Blueprint - Epic Developer Community Forums) I have a new problem

I get the materials to change, i.e. the floor. But when my wood floor switches to a carpet, the reflections in the glass and other reflective surfaces are still of the wood…
Can I update reflection captures during runtime?

I thought of turning the ReflectionCapture objects into Blueprints, give them a Custom event that fires a “Update Capture” and then trigger these each time a new material has been chosen via UMG Material Switching…

My problem is: I cannot find a node that says something like “update Capture” and my Google-Fu is kinda low today and I cannot find anything about this…

Can you tell me if
a) this is possible during runtime
b) a node that can actually do this
c) my idea of linking the blueprints make any sense

Thank you very much and have a great day!


TL;DR = It says in the documentation that the Reflection Capture Actors are updated before runtime… but what about changing materials during runtime? Is there a way to the material change with an “Update Capture”

The engine doesn’t support rendering reflection probes in the game, it can only do that in the editor.

Those reflection probes are very specifically and strictly static, saved before the game ships. They can be updated in real time in the editor, so maybe if you were awesome at editing source code you could bring that feature to your game.

Otherwise, you would have to cook up a more performance-expensive solution like a SceneCaptureCube or Cubemap texture inside every material.

Thanks for your answers, but… hm meh… ok…

Anyone got a workaround?

You could try capturing an HDR cube map of the finished level and use that in your Post Process for the reflection. This way is not going to give you super accurate results but it will allow you to change things without having to worry about artifacts. You can read more about how to use Cubemaps in UE4 from the following .

Cheers-

Sam

Thank you, will have a look into it!

, I’ve been hoping in vain for this functionality with every update since release. It seems to be a simple thing as it already works in-editor. The only apparent reason things like this haven’t been exposed is because VR and other gimmicks unfortunately take priority over actual functionality and creative control. I’m incredibly disappointed with where the engine has been going, all its potential is being neglected in favor of dumbification, so that everyone who wants to make generic games with as little effort as possible can fulfill their dreams of being yet another generic #indiedev.

Technically reflection captures are static lighting. You can force a recapture at runtime though with the console command ‘r.ReflectionCapture’, this will cause a hitch and a lighting pop.

Did this console command get removed in the newer engine versions? I’m not finding it in 4.19.

I think so. It is stored with the lighting data now. What are you trying to do?

Hey ,

in one of my applications I had a similar problem. I was changing light colors of ambient lights using umg, unfortunately the reflections of the light color wouldn’t update.

However, I used the workaround mentioned by DanielW: I created a “execute console command” node and put in the command ‘r.ReflectionCapture’. It is triggered everytime the user applies the changed material. the user will see a loading screen for about .2 sec while the reflection captures are updating.

Not ideal, but working.

Another thing that comes to my mind ist experimenting with planar reflections. maybe this’ll work better for you. planar reflections are updated constantly.

Hi all
I’m having the same problem as the OP - glass wall panel and when I change from wood floor to carpet the reflection still shows the timber.
Is there a way to solve this in 4.19?
Planar Reflections seems to have disappeared from 'Rendering/Optimisations??
I’m an Arch Vis UE4 noob!

r.ReflectionCapture doesn’t work in 4.19 runtime :frowning:

Reflection captures can only be updated in the editor, AFAIK,because they are supposed to be pre-filtered, compressed and packaged into cube map arrays offline.

Is this still true in 4.21?

If it is, how do you do a real-time day/night cycle?

(Unreal is supposed to be great at graphics, so I hope this topic is missing some vital information, because in Unity, you can basically update a reflection probe on tick if you want to.)

This would be dynamic lighting. We were talking about static lighting.

If the original question mentioned static lighting, I missed that.

Regardless of lighting, a reflection probe just takes a shapshot of the current scene, regardless of how it is lit.

If it really is true that Unreal can’t do this at runtime, that’s pretty amazing.

I can’t even get my skybox to show up in my spherical captures, so I really hope I’m missing something big here and that someone can tell me.

So, I have build something…

Pros

  • It updates the reflection captures

Cons

  • It does **NOT **work in the packaged game! (because of this check in ReflectEnvironmentCapture.cpp (line 1439))


if (FPlatformProperties::RequiresCookedData())
{
    UE_LOG(LogEngine, Warning, TEXT("No built data for %s, skipping generation in cooked build."), *CaptureComponent->GetPathName());
    return;
}


  • It’s hacky
  • short hickup (which was to be expected)


for (ULevel* Level : World->GetLevels())
{
    if (Level->bIsVisible)
    {
        if (Level->MapBuildData)
        {
            Level->MapBuildData->InvalidateReflectionCaptures(nullptr);
        }
    }
}

FScene* Scene = (FScene*) World->Scene;
if (Scene)
{
    TArray<UReflectionCaptureComponent*> ReflectionCapturesToUpdate;
    for (TObjectIterator<UReflectionCaptureComponent> Itr; Itr; ++Itr)
    {
        if (IsValid(*Itr))
        {
            ReflectionCapturesToUpdate.Add(*Itr);
        }
    }

    bool bOldIsEditorScene = Scene->bIsEditorScene;
    Scene->bIsEditorScene = true;
    World->Scene->AllocateReflectionCaptures(ReflectionCapturesToUpdate, TEXT("UpdateReflectionRuntime"), false);
    Scene->bIsEditorScene = bOldIsEditorScene;
}
else
{
    // IT DIDN'T WORK
 }


Using UE4.21 btw

If anyone can figure out how to get it to work in the packaged game without editing engine source code I’d be very grateful!

It’s kind of baffling that the engine still doesn’t support updating reflection captures at runtime out of the box.

The reason why this doesn’t work in packaged games is because capture data is compressed and packed into texture arrays as part of the level lighting data, so all the code that does that is part of the editor and not the runtime. Also, a crucial element of reflection capture processing is generating the mip maps, which AFAIK is pretty expensive since you can’t simply downsize each cubemap side as you’d do on a 2D texture: it needs to be resampled in spherical space to be able to blur correctly across the cube face boundaries.