Reading GBufferVelocity in Material Editor or UMaterial

I’m trying to save the velocity map in GBufferVelocity by using SceneCaptureComponent2D, but as a new Unreal user, I’m not really sure how I should proceed:

  1. So the most natural way for me would be create a post processing material and use it as an blendable in SceneCaptureComponent2D

However, similar attempt failed using the Material Editor creating the post-processing material: (page 2 with the following HLSL code):

https://forums.unrealengine.com/development-discussion/rendering/64183-pixel-tracking-methods-optical-flow-methods



MaterialFloat2 UV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);
FScreenSpaceData ScreenSpaceData = GetScreenSpaceData(UV, false);
return ScreenSpaceData.GBuffer.Velocity.xy;


Basically he tried to read the ScreenSpaceData for UV, but he failed (neither did I suceed using the same workflow).

The question is, is there a node similar to Scene Depth node for the velocity?

  1. Since it is not working too well, writing a material shader and then including all the required header files.

I was wondering, what the best example for writing post processing materials by using C++ is?

  1. The other possible way that I thought of is to override the rendering code for SceneCaptureComponent2D.

Is there a way to add effects similar to a post processing pass instead of just a blendable?

Or what is the equivalent function in for



void FPostProcessing::Process(FRHICommandListImmediate& RHICmdList, const FViewInfo& View, TRefCountPtr<IPooledRenderTarget>& VelocityRT)


in SceneCaptureRendering.cpp?

  1. Or maybe I’m doing this totally wrong, and I should just some how save the ScreenSpaceData.GBuffer.Velocity.xy; using a shader in the rendering thread?

Any help would be appreciated, thanks!

It seems that at least the second way was deemed hard at 2014:

Hello,

I was looking for the same Thing. I tried to create a new SceneTexture like the SceneDepth, Worldnormal … I get the new output for the Velocity but i was black. And i read in the Engine that the Velocity system need to be activate … But where i don’t know. I’m curious to know if someone can help us.