bayanm9
(bayanm9)
March 21, 2019, 5:56pm
22
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!
Can you please share where do you enter this code?
are you replacing the code after line 1439?
You just place the big code block in any actor you like. Trigger it with a key or a timer ever 5 seconds to test maybe.
frezer748
(frezer748)
May 9, 2019, 10:35pm
24
I am also looking for a similiar technique like the “Environment Probe” in CryEngine. Because there you could have multiple level/layers with different times of day and it automatically updates the reflection capture when switching the lighting conditions. Currently I always have to rebuild reflection capture when I unhide a certain level with another time of day(Directional light in it) to get a proper reflection in the scene. Or is there a different way to achieve this in UE4?
S-Dot
(S-Dot)
May 9, 2019, 11:00pm
25
Are you using lighting scenarios?