Kink3d / kMotion

Motion Blur for Unity's Universal Render Pipeline.
MIT License
269 stars 33 forks source link

Help getting this to work on 2019.4 #9

Open PpHammer opened 4 years ago

PpHammer commented 4 years ago

Hi!

We are in need of proper motion blur of our new game. This looks great but we cannot seem to get it to work. Not even after implementing some fixes as mentioned under the pull requests.

We're implementing it into a racing game. Motionblur is only working for the bottom right quarter of the screen. When driving backwards it seems better.

Can the asset get a bit of TLC to get it to work under new(er) Unity versions.

I suspect that Unity's own implementation will take a some time :(

Cheers & thanks, Pieter

EsiNikko commented 4 years ago

Hi. I'm already using it in Unity 2019.4.x with no problem, but I had to apply some fixes that I suggested in the pull request. I even added the ability to filter motion-blurred objects with a LayerMask field. I will push this new feature in another branch someday soon. by the way, if you tell the exact version of the Unity you trying to use, I'll give it a try and let you know if I had any solution.

PpHammer commented 4 years ago

Hi EsiNikko!

Thanks for your reply! I am on 2019.4.2f1 and URP 7.4.3.

I can get it to work - more or less - as per your fixes but I am not getting proper results. Weirdly enough when I drive backwards the effects seems to work ok - when racing forward I only have the effect in the bottom right.

The camera is following the car - it is not linked or anything - it is just following it in LateUpdate. Don't know what to check yet atm... :(

PIeter

PpHammer commented 3 years ago

I just can't get it to work in 2019.4.12.

I have implemented the changes as suggested by EsiNikko, but the best I can get is motionblur when moving backwards. Or motionblur on the right side of the screen - but smeared to the right.

It also 'ticks' as if one frame it is rendered the other frame it is not - my guess is that this is related to my camera being updated in fixedUpdate.

Long story short - this seems to be the best solution for object motion blur for urp at the moment - but it is a bit fiddly to get to work

PpHammer commented 3 years ago

BlurLowerRight

This is the effect I currently have - this happens when the camera is moving forward.

Anyone?

fleity commented 3 years ago

I have this setup using @EsiNikko branch and while it does work somewhat I can probably report the same issue as PpHammer. I spin an object in a circle and during 3/4 of the rotation the motion blur works but during one quarter the object is not blurred at all. It seems dependent on the view direction of the camera as it is always the same part of the rotation (lower right part of the circle, towards the camera). Unity 2019.4.16f1 - URP 7.5.3

ThomasChen1220 commented 3 years ago

I looked into the code and the reason why it's doing this is probably because the velocity texture is using RGBA32 when it should be using RGFloat. image

To fix this, in MotionVectorRenderPass.cs after line 49, add : cameraTextureDescriptor.colorFormat = RenderTextureFormat.RGFloat;

Also in MotionVector.shader, change line 20 to this: TEXTURE2D_FLOAT(_MotionVectorTexture); SAMPLER(sampler_MotionVectorTexture);

fleity commented 3 years ago

Over on EsiNikko's and my fork we fixed that texture format issue and a bunch of smaller other issues as well. Additionally to the RGFloat format (which isn't supported on many mobiles devices I've heard, probably the reason it was a more regular one) you have to change the shader to (un-)pack it correctly and when clearing the texture clear it with 0.5 instead of zero.