Seamless Portals

How can I make this work with a CanvasRenderTarget2D?

Just feed the CanvasRenderTarget2D directly to the SceneCapture (“TextureTarget” variable). To create the CanvasRenderTarget2D at runtime use CreateCanvasRenderTarget2D().

But how do i replace the missing functions like GetTexture(), SetFilterMode(), AttachToComponent() and other stuff like Gamma, WrapModeX, WrapModeY, etc?

You should take the time to understand how a SceneCapture and a RenderTarget work, because your questions here would be already answered. See for example: UTextureRenderTarget2D | Unreal Engine 5.2 Documentation

Would you consider releasing the portal mesh? I can grasp the concept but im no modeler.

Also im getting an error in ExedrePortal.cpp in the TeleportActor function telling me that EC is an undefined pointer when the definition AExedreCharacter* EC is clearly defined. Im using Visual Studio 2019 if that means anything.

When I try to implement the BlueprintNativeFunctions in the .Cpp file it tells me that the _Implememtation is not a defined function.

I will see if I can add an little obj mesh to the article, but no guarantee on that.

You don’t provide enough information for me to help your here. Note that AExedreCharacter is my own Character class, you may want to replace it with yours.

You likely made a mistake in how you declare the function in the header. The “_Implemention” function is something the compiler will look for if you added the right tag in the UFUNCTION() macro. See this article for more details : UE4 UFUNCTION Keywords Explained - Tom Looman

so it crashes when i press play and here is the log i get

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000648

UE4Editor_Exedre_0013!AExedreCharacter::TickActor() [D:\Unreal Projects\Exedre\Source\Exedre\ExedreCharacter.cpp:97]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\Actor.cpp:171]
UE4Editor_Engine!FTickFunctionTask::DoTask() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:283]
UE4Editor_Engine!TGraphTask<FTickFunctionTask>::ExecuteTask() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:849]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:692]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:587]
UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1478]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:558]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1523]
UE4Editor_Engine!UWorld::RunTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:783]
UE4Editor_Engine!UWorld::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1558]
UE4Editor_UnrealEd!UEditorEngine::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1693]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:414]
UE4Editor!FEngineLoop::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4850]
UE4Editor!GuardedMain() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Launch.cpp:169]
UE4Editor!GuardedMainWrapper() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
UE4Editor!WinMain() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:268]
UE4Editor!__scrt_common_main_seh() [d:\agent_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

the line of code is in the TickActor function and here is my tick actor function

void AExedreCharacter::TickActor(float DeltaTime, ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{

Super::TickActor(DeltaTime, TickType, ThisTickFunction);
if( UGameplayStatics::GetPlayerController(GetWorld(), 0) != nullptr )
{
AExedrePlayerController* EController = Cast<AExedrePlayerController>( UGameplayStatics::GetPlayerController(GetWorld(), 0) );
-> (THIS IS THE LINE) EController->PortalManager->Update( DeltaTime );
}

}

EDIT:

I changed EController to EPC which i have store in my character class as “class AExedrePlayerController* EPC;”

So it is

EPC = Cast<AExedrePlayerController>( UGameplayStatics::GetPlayerController(GetWorld(), 0) );
EPC->PortalManager->Update( DeltaTime );

then i get this crash log

LoginId:7cad57a24f7b1ce912ff3298e4150829
EpicAccountId:70d466d0e6ec4926a420f91025f5ee5d

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000140

UE4Editor_Exedre_0014!AExedrePortalManager::UpdatePortalsInWorld() [D:\Unreal Projects\Exedre\Source\Exedre\ExedrePortalManager.cpp:171]
UE4Editor_Exedre_0014!AExedrePortalManager::Update() [D:\Unreal Projects\Exedre\Source\Exedre\ExedrePortalManager.cpp:152]
UE4Editor_Exedre_0014!AExedreCharacter::TickActor() [D:\Unreal Projects\Exedre\Source\Exedre\ExedreCharacter.cpp:97]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\Actor.cpp:171]
UE4Editor_Engine!FTickFunctionTask::DoTask() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:283]
UE4Editor_Engine!TGraphTask<FTickFunctionTask>::ExecuteTask() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:849]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:692]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:587]
UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:1478]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:558]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1523]
UE4Editor_Engine!UWorld::RunTickGroup() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:783]
UE4Editor_Engine!UWorld::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1558]
UE4Editor_UnrealEd!UEditorEngine::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1693]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:414]
UE4Editor!FEngineLoop::Tick() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4850]
UE4Editor!GuardedMain() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Launch.cpp:169]
UE4Editor!GuardedMainWrapper() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:137]
UE4Editor!WinMain() [D:\Github\UnrealEngine-RTX\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:268]
UE4Editor!__scrt_common_main_seh() [d:\agent_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

here is the line in updateportalsin world

FVector PlayerLocation = Character->GetActorLocation();

and update

—> if( Portal != nullptr )
{ UpdateCapture( Portal ); }

and tickactor

EPC->PortalManager->Update( DeltaTime );

I think its possible having trouble getting the Character and PlayerController. What does your custom GetCharacter() and GetPlayerController() look like?

Learn how to debug code to solve your crash. You probably have a nullptr.

also question regarding your fast render target rendering, since i want to use that to render the portals

these two functions

// Setup the Slate window with the widget
void UExedreScriptedTexture::UpdateSlateWindow() {
SlateWindow->SetContent( RenderingWidget->TakeWidget() );
SlateWindow->Resize( 256, 256 );
SlateGeometry = FGeometry::MakeRoot(Settings.Size, FSlateLayoutTransform(1.0f)); } // Render/Draw the texture

void UExedreScriptedTexture::Render( float DeltaTime ) { // Use the FWidgetRenderer to Draw the // Slate window and its widget into the texture

Renderer->DrawWindow( ScriptedTexture->GameThread_GetRenderTargetResource(), // FRenderTarget* RenderTarget SlateGrid.ToSharedRef(), // TSharedRef<FHittestGrid> HitTestGrid SlateWindow.ToSharedRef(), // TSharedRef<SWindow> Window SlateGeometry, // FGeometry WindowGeometry SlateGeometry.GetLayoutBoundingRect(), // FSlateRect WindowClipRect DeltaTime, // float DeltaTime false // bool bDeferRenderTargetUpdate ); }

what is Settings.Size and i keep getting an error when trying to use DrawWindow. Its like it isnt recognized as being valid.

It’s a typo, bad copy paste from my code when I wrote the article. It’s a FVector2D that should be the same size as the SlateWindow resize call on the line just above. I will fix my article, thanks for catching that !

Some advice:

  • Take the time to read and understand the code, otherwise you are in for a lot of pain and troubles if you just copy/paste. Read the engine code to understand how the functions I use work.
  • Don’t bother with my RenderTarget article if you only plan to use it for rendering your portals, you won’t gain any performance with it. A SceneCapture doesn’t use Slate/Canvas to render into a texture, the rendering system writes directly into it.

Okay, so I’m getting this problem. Only when I’m inside the portal the rendering works. When I’m out, the scene “freezes”.
Is not my first time trying to do this tutorial (It’s a great tutorial btw) and in the past I have had this same problem.
Everything else works fine, the teleportation (orientation and rotation), the mesh “stretch”, whitout errors in the code. So… can anyone help me out?

vídeo: ZeroPortal - Unreal Editor 2021-02-09 10-13-26.mp4 - Google Drive

ah I realized that some people are having trouble making the Portal Mesh (just like me)
After several attempts I got a result similar to the tutorial. For those who want, I’ll leave a link with the download of the Mesh

Portal Mesh: PortalMesh.fbx - Google Drive

I am unfamiliar with C++. Can someone please provide me with the completed project files?

I have the same problem. does anyone know how to fix this? This is my last unsolved problem

Unfortunately not. I never managed to solve it. Just wrote my own portal system instead.

Looks like I missed some replies to my thread, the forum transition didn’t help it seems.

Looking at the video posted by @NiordErmin it feels like the Portal is looking the wrong way, or something alike, and therefor the rendering is culled/skipped making the render glitch like that. Maybe you have a wrong detection or direction being computed somewhere ? It’s hard to tell from the video alone.

Several people have now followed my tutorials without much issues (most of the time it was little details, nothing as serious as what is showed here in the video), so I would suspect a faulty step here. But maybe there is a step not properly explained in my tutorial. Hard to tell right now.

In order to debug all of that I would suggest to use a lot of the draw debug functions to draw lines, spheres, coordinates, etc and check that everything is aligned as it should be, that you detect the player properly, etc.

I also have this problem and I even used you PortalMesh model but I still have this issue.

Anyone else find a solution?

Actually I managed to finish this project (after some time). I fell into the lines of code and find out my way. Now the portals are working (I guess)

but I noticed that the portal only works if both are opposite. If they are rotated in different directions they don’t work. It’s been a while since I’ve worked on this project, so I don’t remember very well what I did to make it work. If you allow, I can share this project with the community. Most of the code is yours. It’s a empty project, just with the portals.

@NiordErmin Could you, by any chance, also share the .blend file? I have been trying to create the same mesh in Blender (when trying to follow ’s tutorial) but my model always ends up not working with the shader code even though it looks completely correct in Blender. I wanna inspect your project file and try to figure out what I’ve been doing wrong.

It’s also good to have the .blend in case someone wants to edit/improve your mesh.

Dude, you are lucky. I looked deep into my HD and finally found the Mesh. I exported it again and put it in the project to see if it was the same. It’s all right, feel free to play with the Mesh.

https://drive.google.com/drive/folders/1edhfgeZvShXJ3GzpP2jUTpOtvoDTVrVh?usp=sharing

Ok ok, It’s more professional to use github right? For me it’s easier to just send the google drive link, but it’s there on github too