hmmm I aimed my render target at some moving objects and the screen is black.
Does the deferred shader not have the GBuffer.velocity as the base pass pixel shader? In BasePassPixelShader.usf, there is a comment that says “2d velocity, includes camera an object motion” and then below it gives the following code:
float2 Velocity = Calculate2DVelocity(BasePassInterpolants.VelocityScreenPosition, BasePassInterpolants.VelocityPrevScreenPosition);
float2 Velocity = Calculate2DVelocity(MaterialParameters.ScreenPosition, BasePassInterpolants.VelocityPrevScreenPosition);
// Make sure not to touch 0,0 which is clear color
GBuffer.Velocity = float4(EncodeVelocityToTexture(Velocity), 0, 0) * BasePassInterpolants.VelocityPrevScreenPosition.z;
If they are not the same velocities, is there a way to get access to GBuffer.Velocity in the base pass?
What is the whole code of your custom node right now?
Just trying to make sure that the scene texture as plugged in isn’t involved.
I am honestly not exactly sure at this point as it gets a bit outside of my coding experience, especially in terms of all the specifics involved here.
Brian did mention that they planned to re order some render passes in the future to make this sort of thing cleaner to properly expose but he seemed to think this should be possible now in the custom node as long as the project setting is enabled and scenetexture is hooked up somewhere in the material.
I looked over the UE4 code (DeferredShadingCommon.usf, BasePassPixelShader.usf) and the GBuffer.Velocity should be there, but accessing it on the material from a custom node always returns a black image. Accessing other buffers like Metallic and WorldNormal work as expected from any custom node.
I have blur set to 1 on my postprocess volume, and “Accurate velocities from vertex deformation” enabled on project settings (Rendering section, optimizations).
That might be a bit of help I guess, before the command “VisualizeTexture GBufferVelocity RGB UV0” showed the motion vectors, so I guess now it would be “VisualizeTexture velocity RGB UV0”, that should make it fullscreen, modify the code of the visualizetexture command and remove the info text in the center of the screen. But still, I don’t think you can export this pass in high bitdepth so its kinda useless.
Oh also, when I did “VisualizeTexture GBufferVelocity RGB UV0” the texture resolution was like 1280x600 so it didn’t work with every aspect ratio, and when having different FOV it would be also mismatched.