Im trying to prototype a simple material with a custom GBuffer texture.
What I have done so far is:
-Create a new actor with a scene capture component
-Align this actor with the current view so the texture matches the GBuffer
-Capture whatever object I want
-Composite the buffer with a post process material
Seems simple enough but so far Ive encountered several problems:
->Aligh the actor with the view:
At first I though of using the ue5 scene capture “Main View” settings to keep view aligned, but found out that this settings only work if capture every frame is enabled and its not suited for rendering things if they are not going to be seen on the main view.
So I had to get a list of objects and toggle the visibility before rendering them:
Scene capture->UseShowOnlyList
Set selected actors visibility → true
SceneCapture->CaptureScene
selected actors visibility → false
Cant composite a translucent buffer without depth information:
I need the objects to be depth tested against the main scene (there is no way of doing this using show only list), they are translucent too so I cannot use render RGB with depth in A. I need access to the scene depth to perform this depth test
I then created another render target to store the scene depth, probably there is a quick way to write the Depth buffer to a texture or using it directly, I have tried “DrawMaterialToRenderTarget” but doesnt seem to work with pp materials, so I ended up using the scene capture to just capture the depth to a texture before capturing the objects.
Now, I set the resolution and FOV for each texture but the end result just doesnt match. Im using the default UVs on the post process material so they are 1:1.
Im updating the actor position every frame too.
This is the result:
I dont know if this is expected behavior but the camera manager data is not correct. Furthermore when moving there is a noticeable delay/lag. I have tested that the camera manager position doesnt match the player camera and the raw player camera doesnt match the player camera manager or the final view either.
My question is simple, how am I supposed to get the camera position/rotation in unreal ? Is it possible to align a scene capture to the player view? Seems pretty simple.