Download

Outputting custom vertex data information from internal shaders for use in a plugin

Hi, for an existing plugin, I had the need for 2-D pixel velocities and was able to accomplish this by creating an Unreal Material which uses the Velocity GBuffer using the SceneTexture node. However, I now also have need of the 3-D pixel velocities (absolute vertex position differences between consecutive frames). I could accomplish this as a hack by modifying the BasePassVertex/PixelShader.usf files however this isn’t a sustainable solution since the Velocity GBuffer is used by a lot of other things as well. I was wondering what the best way would be to implement this functionality, either by modifying the engine code or by adding custom shaders in the plugin itself. I tried looking at some resources for adding custom global shaders in a plugin but I’m not sure this would be relevant since I would need access to the vertices current and previous positions for the scene. I think the easiest way would be to modify the Engine/Shaders/Private/VelocityShader.usf file however I was unable to understand how to use this file from the plugin side.

Any help would be much appreciated. Thanks.