Announcement

Collapse
No announcement yet.

Pixel Tracking Methods: Optical Flow Methods

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Your material will always have to be translucent in order to read any of the gbuffer stuff including scene texture.

    The other error is you are trying to use a 3d vector to specify the 2 coordinate UVs for the scene texture. That should just be screenposition there.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #17
      Click image for larger version

Name:	Capture3.PNG
Views:	1
Size:	124.1 KB
ID:	1098157

      My code is compiling and I have no errors but I am only getting 0's/black screen for the output.

      I noticed in DeferredShadingCommon.usf, that it will only write to velocity to GBuffer if WRITES_VELOCITY_TO_GBUFFER is enabled. How do I make sure that setting is enabled?
      Attached Files
      Last edited by GrohBot; 01-07-2016, 03:45 PM.

      Comment


        #18
        That is under project settings -> rendering, called "support accurate velocities for vertex deformation". Turn it on.

        And yes my bad I meant translucent or post process materials. The log saying opaque threw me, that warning could be improved.
        Ryan Brucks
        Principal Technical Artist, Epic Games

        Comment


          #19
          Ok I had "support accurate velocities for vertex deformation" enabled, can you think of any other reason why I am not getting any useful output?

          Comment


            #20
            Maybe you have no dynamic moving objects?

            The gbuffer velocity channel only include dynamic objects that have motion. Static world motion (which only blurs when camera moves) is calculated using some math involving previous camera transform. You'd have to calculate that part manually currently. Doesn't seem terribly crazy but maybe a bit tricky.
            Ryan Brucks
            Principal Technical Artist, Epic Games

            Comment


              #21
              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:

              #if WRITES_VELOCITY_TO_GBUFFER_USE_POS_INTERPOLATOR
              float2 Velocity = Calculate2DVelocity(BasePassInterpolants.VelocityScreenPosition, BasePassInterpolants.VelocityPrevScreenPosition);
              #else
              float2 Velocity = Calculate2DVelocity(MaterialParameters.ScreenPosition, BasePassInterpolants.VelocityPrevScreenPosition);
              #endif

              // 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?

              Comment


                #22
                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.
                Ryan Brucks
                Principal Technical Artist, Epic Games

                Comment


                  #23
                  Click image for larger version

Name:	Code.PNG
Views:	1
Size:	25.7 KB
ID:	1098182

                  MaterialFloat2 UV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);
                  FScreenSpaceData ScreenSpaceData = GetScreenSpaceData(UV, false);
                  return ScreenSpaceData.GBuffer.Velocity.xy;
                  Attached Files
                  Last edited by GrohBot; 01-08-2016, 01:16 AM.

                  Comment


                    #24
                    bump! GrohBot, did you manage to finally get access to the previous frame's world position?

                    Comment


                      #25
                      Bump X2! This would be really awesome to be able to do.

                      Comment


                        #26
                        Bump X3 - I'd be really interested in being able to do this...
                        Carlos Montero | @cman2k | Technical Art Director @neoglyphic
                        Working on Sunborn Rising and the Neofur Plugin | I made Black Mesa

                        Comment


                          #27
                          bump x4 - also something I'm after
                          Work Tutorials

                          Comment


                            #28
                            Also interested.

                            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).

                            Working example:
                            Code:
                            MaterialFloat2 UV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);
                            FGBufferData GBData = GetGBufferData(UV, false);
                            return GBData.Metallic;
                            Does not work:
                            Code:
                            MaterialFloat2 UV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);
                            FGBufferData GBData = GetGBufferData(UV, false);
                            return GBData.Velocity;
                            Setup is the same as GrohBot's.

                            So, the Velocity GBuffer is not being written to. Any ideas on why is that happening? I see forcing it should be easy by modifying some lines, but client uses launcher build. Thank you.
                            Last edited by Sithdown; 06-16-2017, 08:22 PM.

                            Comment


                              #29
                              I am also interests in extrcat motion vector. but I don't know how.
                              I search for ue4 source code for gbuffer velocity.
                              Hope it can help you guys.

                              Click image for larger version

Name:	ue4_Velocity.png
Views:	1
Size:	72.8 KB
ID:	1129904

                              Comment


                                #30
                                visulize velocity

                                Click image for larger version

Name:	ue4_velocity.png
Views:	1
Size:	582.8 KB
ID:	1129941
                                I can use this cmd to visulize velocity, Is it help a bit?

                                Cmd: VisualizeTexture velocity

                                Comment

                                Working...
                                X