Motion blur during camera flyby in skybox

Hello! I can’t get the motion blur effect to occur when the camera flies in the skybox. Help me please!
https://playground.babylonjs.com/#UU7RQ#3088

I think it is because it only relies on object motions not camera motions :frowning:

cc @julien-moreau and @CraigFeldspar

I slightly modified the motion blur example from the documentation, the fixed sphere and the environment have the motion blur effect when the camera rotates, but when the camera zooms out and zooms in, there is no motion blur effect.
Also, if you install a free camera, only rotation gives the effect of motion blur, and when moving the camera in all directions, there is no effect.
Please help me understand how it works. In which direction to dig to make the motion blur effect for the entire environment when the camera is flying.
https://playground.babylonjs.com/#E5YGEL#24

Hey there @D_Taylor ! Apologies for not following this through, me and @sebavan are checking right now :slight_smile:

I think that motion has some quirks in the shader but they might be by design.

We do use the depth prepass or geometry buffer prepass which are depth from the camera point of view but in the motionBlurPostProcess it looks like we consider them in NDC space as we apply view proj. Also the multiplication order for view proj looks different than the thransformMatrix one of the scene which is suspicious.

@julien-moreau I am not sure if it is a bug or a bad understanding on my side ?

@Evgeni_Popov what do you think ?

Yes, the multiplication of the matrices is inverted compared to what we do normally, but in the shader code the transformation of a point P is done by p * mat instead of mat * p… I think it is supposed to give the same result in the end but I could not make it work with this order of multiplications…

Anyway, I could make it work on my local computer after I made those fixes:

  • the depth buffer was not passed correctly because depthSampler was not declared in the list of samplers
  • the depth recorded in the depth buffer is indeed not the right one, the motion blur expects a non linear NDC value whereas we record a linear camera view value
  • I changed the order of the multiplications for the 3D coordinate transformations in the motion blur shader
  • Also, in the shader, there is a missing cpos /= cpos.w;

I will make a PR tomorrow as it is already late and I have to clean my code.

1 Like

I think that motion has some quirks in the shader but they might be by design.

We do use the depth prepass or geometry buffer prepass which are depth from the camera point of view but

This has been merged earlier today in a PR from @carolhmj :wink:

1 Like

I have found that using a sphere is far better than a skybox, because a sky box is implemented using a 3d texture. This greatly limits resolution. Assigning a very high res texture does not make it less blurry, and this is “standing still”.

I have a scene, where I used a NASA enhanced milky way texture in a sphere. It was a used space craft sales lot scene in XR. You could fly via teleporting to different pads that had different crafts. Great res, zero blur even when flying.

Here’s the fix:

3 Likes