HDRP Wheel Motion Vector.

Motion blur has always been a problem with fast rotating objects. It looks very bad on car wheels. I know HDRP will allow Custom motion vector in shader graph in the future, but is there no way to fix the motion vector of wheels right now?

While examining the custom pass volume, I realized that I can choose motion vector in material pass name. I wonder if I can do it using this.

6409386--715722--upload_2020-10-12_17-13-5.png

I’ve done this on the old style way (there’s an example from PPv1 for custom movecs for wheels). That sample just used additional cage mesh with shader that mainly had movec pass on it. You’d want the cage mesh if your wheel meshes have holes but otherwise you could probably go with that custom pass route for movecs.

You need to mod the shader a bit to function in HDRP, at very least you need to change line 15 to:

ZTest Less Cull Back ZWrite Off

You need this so the ZWrite doesn’t prevent the underlying mesh from rendering.

There are few additional issues with this setup which are not HDRP related (but apply to it as well). That shader only spins the wheel on one direction due to a logic error. To fix that you can swap line 60 to:

c.rg = (c.rg * 2.0 - 1.0) * abs(_MotionAmount); // Using color texture so need to make 0.5 neutral

Additionally, the shader doesn’t scale the motion amount by the wheel size on screen so you have to implement some sort of scaling logic to prevent this from happening if you can zoom in and out to wheels in your gameplay.

Edit: You also need to change the movec pass queue to make sure you actually render the movec after rest (required for newer HDRP versions, shouldn’t hurt to do in the old versions either). You can do it like this:

    SubShader
    {
        Tags { "Queue" = "Geometry+500" }
        Pass
        {
            Name "Motion Vectors"
1 Like

thanks. current problem is that the shader renders before the unity motion vector.
6412923--716412--upload_2020-10-13_13-59-26.png

It has no effect on motion blur other than the sorting issue.


@AydinDeveloper Oh right, I forgot they changed the queue order a bit in recent HDRP, you now need to change the queue in that movec shader as well.

Edit: moved the code snippet to my earlier post in case others stumble to this thread.

1 Like

Hi all. Do you have a working example of custom motion vectors for HDRP to share?

You mean the instructions I listed doesn’t work anymore?

That being said, this could potentially used for this effect as well: https://github.com/Unity-Technologies/Graphics/pull/4931 (not merged yet)

1 Like

@rz_0lento I fixed the problem months ago. I forgot to thank you for your help :slight_smile: When I added stencil buffer to the shader, I managed to run it properly. but HDRP motion blur effect could not provide the quality blur I wanted.

I found a better solution. Not as an image effect. I’m doing a Blur with a normal object shader. In this way, I get a better quality result than image effect motion blur.

URP

3 Likes

[quote=“Muhammed Emin Aydın, post:8, topic:812408, username:AydinDeveloper”]
I found a better solution. Not as an image effect. I’m doing a Blur with a normal object shader. In this way, I get a better quality result than image effect motion blur.
[/quote]Looks nice, this is traditional preblurred image over regular mesh kinda trick or do you sample the scene color for this?

1 Like

I created it based on the URP motion blur shader. I’m sampling the scene color with this texture. There are a few problems.

I don’t know what color I should apply for the other surface of the wheel. As shown in the screenshot, Scene color does not work in Scene view, with MSAA turned off or with Deferred rendering. This may be related to the Beta version. or the custom function is related to the way I write. I will rewrite with normal shader soon. HDRP and Default RP will be pretty easy to support.

2 Likes

I tried, but gave up after 30min.

Instead istarted to try to port this “overhead” kinda “brut force” Motion Blur method to HDRP.
Half way done but i expect some tranparent sorting issues.
However some high quality result should be possible with this.

check the Unity WEBGL
https://nothke.itch.io/volumetric-mesh-blur?secret=GA3D2cuKm8VJpNMu6PNA2Ei6Zl4

and the method behind
http://nothkedev.blogspot.com/2018/10/correct-motion-blur-for-fast-rotating.html

This guy reworked this method with less code and more manually work (copying) needed.
But gives an idea what to expect.

https://www.youtube.com/watch?v=v1rQPb1U2jE

1 Like

Here are the two scripts from the video tutorial.
Add the scripts, a rigid body and a wheel collider to the wheel.
Works nicely so far.

7507013–925385–WheelTest.cs (663 Bytes)
7507013–925388–VolumetricMotionBlur.cs (1.02 KB)

@keeponshading It has HDRP Custom Velocity support. I no longer have any problems.

wow. This looks fantastic.
Does the TAA works too when the car is driving and
how you did it? .-)

I have
6 different HDRP Lit materials for the rim
3 different HDRP Lit materials for the tire

7508749--925739--1.JPG

This should render something like this.
But at the moment with default settings the TAA and MotionBlur goes crazy several cm around the complete wheel.

7508749--925742--2.JPG

I set TAA speed reject to 0.2 (HDRP 11+)
in this way, TAA is not processed on very fast objects.

Nice. Didn t know that.
How can i setup the HDRP Lit shader or an HDRP Shadergraph.
Only enable custom velocity and the motion vectors know then they have to rotate?

Hi!
Solution with transparent materials for rims works for me!
But I have more general problem with hdrp motion blur - objects, far from moving camera are jerking. So, i.e. having car hood camera, driving fast, steer slowly, far objects sometimes partially blurred (i mean partially random on each frame, it looks like permanent noise).
Are there any solution for it?
It seems there are lack of some filtering.

The same noise exists for SSR (HDRP 12). I.e. in Unigine engine there are no noise at all.

Which technique that you use for this one?