Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Motion Blur Support #87

Closed
TripleDots opened this issue Feb 21, 2018 · 30 comments
Closed

[Feature Request] Motion Blur Support #87

TripleDots opened this issue Feb 21, 2018 · 30 comments

Comments

@TripleDots
Copy link

TripleDots commented Feb 21, 2018

As seen in the image, motion blur does not affect anything created with the fluids (incl. white water particles.) But it also remove any blur on the moving object whether it's in or behind the fluid.

Tried both CPU and GPU rendering in Cycles but neither worked. It's actually kind of a cool effect.

moblurtest

(The large blobs near the head are shooting up very fast. Even with a 360 shutter angle it's not showing any motion blur.)

Weird thing is that I followed this particle spark effect and it does render motion blur no issues. https://youtu.be/QCMyvcc3ZaU

But I noticed that in the beta test video there is motion blur on a few clips. https://youtu.be/5s7L3ruVaXk
Is that post processing trickery or am I missing a feature here?

Depth of Field however does render correctly on the fluids and with objects in or behind the water as seen here. (Also tested on both CPU and GPU.)

doftest

EDIT: it's the same blend file as here #86 but with Susan made a bright orange to show the effect, the cylinder hidden from camera view and black background added.

@rlguy rlguy added the feature label Feb 21, 2018
@rlguy
Copy link
Owner

rlguy commented Feb 21, 2018

Motion blur is not supported at the moment. It's something that we really want to be able to add but we haven't found a way to pass velocity data into Blender Cycles from an addon so that motion blur can be rendered. In the video, motion blur was added in post-processing.

At the moment, I think the most likely way to get motion blur support would be to add a feature to export to an alembic cache and attach the velocity data. But I think this still needs to be implemented in Blender. There is a Blender issue (D2388) discussing this, but it looks like no one is working on it at the moment.

I have converted this issue into a feature request/discussion. If anyone has any ideas/tips for how to add motion support, please let us know!

@rlguy rlguy closed this as completed Feb 21, 2018
@rlguy rlguy changed the title Fluid (w/ particles) motion blur issue [Feature Request] Motion Blur Support Feb 21, 2018
@rlguy rlguy reopened this Feb 21, 2018
@vmxeo
Copy link

vmxeo commented Feb 21, 2018

Speed Vector passes with Vector Blur is another route for motion blur.

Not sure there's a direct way of accessing that from an addon. There may be some indirect ways, it'd be a kludge though.

@TripleDots
Copy link
Author

I am not at all a programmer so please excuse my basic questioning, but how is cycles rendering their internal fluid system?

(Video of the internal fluid sim with motion blur.)
https://youtu.be/m2yYzhp54qk?t=8s

Also, what you could do is how people force motion blur in compositing for now which is basically layering older frames with 50% opacity. But to do it correctly fluid should be rendered separate so that this only effect fluids and things behind the fluid. If possible with sub frames. Else you get nasty looking motion blur on fast moving objects. IIRC After Effects uses their optical flow(?) technique to create subframes from already existing one. But in the 3D world you could actually generate these frames required. which in theory should look better.
This will probably not help with developing the fluid sim but it might help with working around it in compositing and/or writing a separate plugin.

@vmxeo
Copy link

vmxeo commented Feb 21, 2018

@TripleDots There's a good explanation of motion blur and Blender's internal fluid system here: http://adaptivesamples.com/2016/07/23/motion-blur-dynamic-meshes-cycles/

It also explains why it's not always so straightforward to do on deforming meshes. Other rendering engines also let you render out a separate vector speed passes or AOVs for implementing motion blur later in post, but I haven't found a good way to do that with Cycles for dynamic meshes.

@RevDr
Copy link

RevDr commented Feb 27, 2018

Would setting per vertex colors of the mesh to the velocity values work?

If so, (I think) these could be used within cycles: get the vertex color and transform into camera space. This image could possibly then be used to do a 2D motion blur.

@juangea
Copy link

juangea commented Mar 5, 2018

EDIT: Ok, this was already named by Ryan so... silly additiona by my part :P

Allow me to put a note here that can help a bit with Motion Blur.

In the fracture modifier build the new remesher has now motion blur enabled, I´m not sure if they used this patch or not, but we were talking about it and I think this helped them to enable motion blur in the remesher:

https://developer.blender.org/D2388

This patch is to add motion blur to Alembic caches with variable vertex count meshes, I´m not sure why is not in master, I assume it has not been reviewed and studied enough.

Cheers!

@juangea
Copy link

juangea commented Mar 11, 2018

But RLGuy, this has been already implemented by Scorpion81 in his Fracture Modifier branch, so maybe you can implement it here too, I don't think he modifier Cycles at all, I think he did something to his meshing system, but I think you can do this too since Cycles supports motion blur for fluid meshes and such things, it's just a matter of the information your mesh has and how it presents it to cycles, I think that, but please discuss this with Scorpion81 because he knows how to do this.

Cheers!

@DerFluep
Copy link

Hey RLGuy, the new Version of DualSPhysics is out with Blender support only for rendering but with Motionblur support:
https://github.com/EPhysLab-UVigo/VisualSPHysics
They use animated Shapekeys to deform the Surface within +/- 1 frame. So Maybe Shapekeys are the way to go?

@rlguy
Copy link
Owner

rlguy commented May 25, 2018

Thanks for the tip, I only just learned what shapekeys were just now! I just tested out some scripting for manipulating the shapekeys of an object and it works and renders with motion blur. This definitely seems like the way to go to get motion blur rendering for the fluid surface!

@rlguy
Copy link
Owner

rlguy commented Jun 3, 2018

Motion blur support for the fluid surface has been added in version 1.0.3 (now available). See this document for more information on the status of motion blur rendering for the surface and whitewater: https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Motion-Blur-Support

@RevDr
Copy link

RevDr commented Jun 3, 2018

HI,

Given the instability of the particles: is there anyway, rather than doing the motion blur in the 3D render in blender of rendering a mesh pass with the colors of the mesh and particles set to the motion vectors. i.e. red motion x component, y component is green and z is blue. By rendering out a pass this way it would be possible to do motion blur in compositing.

@DerFluep
Copy link

DerFluep commented Jun 4, 2018

I made a quick test with the new Motionblur implementation:

motionblur

in the front is a regular mesh falling down. I guess the Flipfluid implementation generates a Shapekey only for one frame? I think Cycles uses the frame before AND after the current frame to render precise Motionblur. I guess that is the reason for the hard edge of the blured water mesh?

@rlguy
Copy link
Owner

rlguy commented Jun 11, 2018

Hey, thanks for pointing this out! I had a misconception on how motion blur worked in Cycles and thought the hard edge was normal. I have modified the addon to use shapekey data for both the next frame and previous frame. This fix will be included in the next version update (1.0.4).

motion_blur_fix

@DerFluep
Copy link

Wow now THIS is awesome motionblur!
Thanks for hearing all of our requests and actualy takle them 👍 Can't imagine a reason to buy something like Realflow ;)

Cheers!

@DerFluep
Copy link

Hey RLGuy,
just tested the 1.0.4a motionblur and it works realy well! Only Thinge I noticed is, that the Motionblur strength changes with different resolutions? Sometimes a scale of 3 is „right“ sometimes 5 or more. Is this normal?
Also: is there a Chance to get motionblur for Whitewater particles soon? :)
Thanks for the Great work!

@rlguy
Copy link
Owner

rlguy commented Aug 27, 2018

Hey Corefrecs,

The amount of blur changing between resolutions is a side effect of the workaround that we are using to get motion blur data into Blender. We attach velocity vectors to the vertices of the mesh and use those vectors to create shapekeys to morph the mesh into the previous/next frame. When the triangles become smaller (higher resolution), there is an increased chance of inconsistencies in the mesh such as triangle intersection or face-flipping and when this is resolve in Cycles, it results in a decreased amount of motion blur visually. The workaround for this is to scale the motion blur in the Display panel as you are already doing.

As for whitewater motion blur, it is unlikely that this will be supported for use in Cycles using this workaround. Adding motion blur data to whitewater particles is just too much motion blur data for Cycles to handle and results in instability/crashes with just a few thousand particles. Even using large high detail meshes with motion blur seems to be too much for Cycles to handle.

If you want to try out enabling motion blur for whitewater particles, there is a script to do so here: https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Motion-Blur-Support#whitewater-motion-blur

- Ryan

@DerFluep
Copy link

Ah ok I understand. Are you using the same shapekey technic for whitewater motionblur? Maybe you can just keyframe the "particles"? I havent testet motionblur with so many particles using a simple particle system inside blender so I have no idea if this works (guess not because you said once you're using vertex duplication or something like this for the whitewater particles). Just making suggestions :D

@rlguy
Copy link
Owner

rlguy commented Aug 28, 2018

The whitewater particles are duplicated over the vertices of a vertex-only mesh. This is how we render particles since there is not yet a way to implement some complex behaviour in our whitewater system into the Blender particle system. We use shape-keys to add motion blur data to the vertex-only meshes and then Cycles transfers this motion to the duplicated particles.

Keyframeing the particles individually would require separating each particle into a separate object which would greatly slow down Blender, taking hours to days to load a frame.

Really hope that Blender 2.8 will allow us to implement our whitewater as a particle system. It would greatly simplify loading whitewater and open up a lot of possibilities for creative rendering of particles.

@guitartom47
Copy link

guitartom47 commented Mar 11, 2019

Dumb question: If I import an alembic white water file, it tries to use motion blur on the particles. This motion blur is sometimes very chaotic. My intuition (often erroneous) tells me that perhaps it's based on the vertex index number and that the vertex numbers are not always positioned close to the same vertex number on the proceeding frame. Motion blur and smoke with sub-frames (using the spray object which isn't alembic) both act in this chaotic manor - sometimes crashing blender. If the white water vertices were indexed with their location to more correspond with proceeding frames, would everything work better? It seems to me that it would be easier for blender to calculate it. My assumption is probably wrong but I had to ask. I hope my description makes sense.

@rlguy
Copy link
Owner

rlguy commented Mar 11, 2019

Hey guitartom47,

That's very interesting! I had never thought that Blender would try to derive motion blur from the Alembic cache. My first guess would also be that Blender is using the vertex index of the meshes. And if this motion blur works like the shapekeys workaround, it might be comparing the current frame with both the previous frame and next frame.

The difficult part about getting motion blur to work in this way is that in our whitewater system, thousands of particles are being removed every frame (and also birthed). The vertex order is constantly changing. If Blender calculates two vertices to be the same between frames, and these particles happen to be very far away from each other spatially this will put a huge strain on the renderer when it calculates the BVH tree.

It could be possible to improve motion blur results by ordering vertices in a smart way, but is not so simple to implement. And also, not guaranteed to work.


Lately I have been experimenting with writing the whitewater cache files in the blender .bphys file format that particle systems use. This could make it possible to render motion blur on particles properly and also make it possible to add other rendering effects such as colours based on velocity. But during testing I have run into huge performance problems when trying to load over a million particles:

  • The .bphys cache file sizes are very large compared to our whitewater format. Over 8 times larger. This can result in frames containing over 1GB of particle data for large simulations.
  • Loading large particle data into a Blender ParticleSystem is incredibly slow. It can take minutes to load a frame. Memory usage in Blender is also very high, often requiring 16+ GB of RAM for a single frame.
  • The .bphys cache format requires a file that lists all of the particles that ever exist in the particle sequence. For heavy whitewater simulations where particles constantly die and are born, this file can grow to be many GB large. Larger than Blender can handle. A workaround for this is to split up simulation into a separate particle system for each frame where the sequence is only 1 frame long. The problem with this is that it will further increase the size of the cache files and initializing a new ParticleSystem each frame is incredibly slow and will add additional minutes per frame.

Right now it is not looking very likely that we will be able to implement whitewater particles as a ParticleSystem.

@guitartom47
Copy link

guitartom47 commented Mar 11, 2019

If it were possible (it sounds difficult) to keep track of the particles, it might help in other ways as well! What brought me to this motion blur observation was that I've been experimenting with bringing in an alembic 4th white water 'sand' particle. I had to bake my flip twice to achieve that. My sand is randomized in color, and I suspect that if I were to do closeups, it would have quite a grainy flicker. (I'd like to post about this in the appropriate place as soon as my render completes.) As to color changes, I've been wanting to change the color of my water by using it's proximity to bubbles or foam - thinking this might help to use less particles but maintain realism. There's an attribute node in materials but it won't allow the use of vertex weight. Vertex colors are usable but not for the fluid object (because of it's animation?) - so no dynamic painting unless blender introduces new modifiers to add vertex colors.

Thanks for the response! Hope this helps in some way!!

edit: your decoupling idea might help with the double baking for sand or dust!! It seems like it would take tremendous amounts of drive space though!

@RevDr
Copy link

RevDr commented Mar 17, 2019

RlGuy,
You have probably considered this already, but just in case.

Had you considered using the .bphys format, but using to compress the particle data.

I am not sure if this would work, but If rather than having a separate blender particle for each of yours have a seperate blender particle for each 'live' particle of yours. That would mean that you could reuse blender particles for different flip sim particles. All you would need to is 'park' blender particles at some crazy location when not in use.

For example
Say in FlipFLuids you have a sim with 4 particles which are created and die on in following frames
A - 20 50
B - 30 100
C - 70 80
D - 85 90

You could compress that down to two Blender particles that has 'sensible' data at
A' - 20->50, 70->80 and 85->90
and
B' - 30 100

This should dramatically reduced your files sizes.

However,
a.. This will only work if Blender uses the bphys velocity component to render motion blur and not change in position
b. You won't be able to do some of the usual particle age tricks like change size etc.

Anyway, Just a thought - but you may have had it already.

@rlguy
Copy link
Owner

rlguy commented Mar 17, 2019

Hey RevDr,

I have thought about this a bit. This method would be a workaround to this problem:

The .bphys cache format requires a file that lists all of the particles that ever exist in the particle sequence. For heavy whitewater simulations where particles constantly die and are born, this file can grow to be many GB large.

For example: if the simulation cycles through 100 million particles in a sequence, but at most 6 million are contained in a single frame, this file would only require listing 6 million particles.

But a problem is that this could increase the cache size of a sequence overall if the simulation fluctuates in the number of particles per frame. The .bphys format only allows particles to be born once and die once, so there could be a range of frames where the files would be storing many 'parked' particles.

An example scenario:

  • The simulation peaks at 6 million particles at frame 100
  • Afterwards, many particles begin to die out
  • Then more particles are generated and peaks again with 6 million particles at frame 200

This would mean that the cache files would need to store all 6 million particles between frames 100 to 200. Which is about 500MB per frame!

a.. This will only work if Blender uses the bphys velocity component to render motion blur and not change in position

I would assume that Blender would use the velocity attached to the particle for motion blur

b. You won't be able to do some of the usual particle age tricks like change size etc.

Yeah, there might be some parts of a ParticleSystem that would not work correctly if it uses the particle age. But for material/shading purposes, we could work around this by storing the real particle age in another attribute such as 'color'.


A way to work around having these huge files might be to write all particle data in our own compact format, and then generate the .bphys cache files 'on demand' when loading a new frame. I haven't tested this, but some problems I can think of:

  • I am not sure if a ParticleSystem would function if the cache is being edited live
  • The .bphys cache files must be written to storage. They can't be sent to the ParticleSystem through main memory. Performance for reading/writing hundreds of MB of data when loading a new frame would not be great.

@guitartom47
Copy link

guitartom47 commented May 22, 2019

Well shoot.
Recently, I lost ALL of my most recent simulated work on my project - so, in my frustration decided to give the white water motion blur another go. I'd had good luck with the vector blur node in compositing, renders being less crashy than with motion blur during the render within cycles. The node needs a vector pass and a depth pass, and works well while being slightly less realistic.

The white water vector blur looks WONDERFUL. I don't know if it'll hold up later with more particles, but for now it looks great. I can turn off motion blur individually for the WW objects if I need to. Also rendering the WW blur in cycles seems to work a little better than before? Maybe my imagination - it's also about three times longer render time than with the node. It might be worth putting it into the UI - with warnings.

One image does not an animation make, and I did notice some odd blur the first time I tried it, so I'll post back here if it's absolutely unusable. Very promising though.
motion blur

@guitartom47
Copy link

For anyone who is interested, I am including a link to examples of white-water motion blur made possible by following the directions here: https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Motion-Blur-Support.

From my own memories of trying this months ago, directly in the render, motion blur would sometimes lock up or destabilize the renders of individual frames. What I never realized was that ALL the motion blur data was always present and correct. When I used the vector blur node in compositing instead of trying to render the blur in cycles, every frame stabilized enough to render it out. Unsurprisingly, because of the vector pass, frames took longer because Blender took time to collect info from three frames instead of just one to calculate the blur data.

As I rendered out my animation, I realized that even when just using the vector blur node, some frames were chaotic with respect of the white water blur. The chaos ranged from completely wild to very subtle. Sometimes it was so subtle that I only saw it in the rendered video afterward as a flicker. I never really came to a conclusion as to why it happened. Sometimes I would have as many as ten frames render with no problem, and some days I could get barely any to render. I think restarting the computer may have helped at times. Also I often prayed to the render gods.

Here's the thing. I could get every frame that glitched to render perfectly after another try or two or five. I created a work flow after much frustration that used multilayer openexr as output - so that I could go back and just render the vector pass and nothing else.

Is the render blur problem the fault of Blender or a bug in the FLIP addon? I couldn't tell - but I do know that I've had similar problems using just the fluid object blur - though not as prevalant. In those times I'd monitor the render and see that inividual frames would suddenly, hugely slow down and seem to lock up. SOP was to stop blender in the windows task manager or the system console, open Blender again and then retry.

Included in the link are two examples of my work. It's a sunset scene so I left it a little dark. One scene is how everything should be with correct motion blurred white-water and surface. The other is how it would look if I had left everything un-rerendered. About two thirds of the way though I finally decided that since the foreground was blurred I would give up on the motion blur. All was rendered with Blender 2.79 E-cycles. Surface tension was on but no sheeting. Resolution was set at 1000. (to be self critical I much would have preferred 1400 - I've tried it before and it looked wonderful - but Blender doesn't like that so much. Also so much more time would be involved - a good argument for adaptive fluid sim of some sort)

This animation is still incomplete but I needed to share my findings nevertheless.

Link to downloadable video files: https://1drv.ms/f/s!AuL_h2DNeOJciI4s5gWpYsI5ViPulQ

@RevDr
Copy link

RevDr commented Jul 11, 2019 via email

@guitartom47
Copy link

RevDr, that's beautiful and incredible!! I didn't realize that you were using the same technique! If your renders were more stable, I wonder if the instability happens as blender (or even FLIP) has to juggle more and more data...

@RevDr
Copy link

RevDr commented Jul 13, 2019 via email

@HFutabaH
Copy link

HFutabaH commented May 2, 2021

Don't know if this will be appropriate or relevant, but decided to share anyway.
So far on 2.92 forcing mblur(as described in https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Motion-Blur-Support) works only for still renders. Digging a little bit i was able to make it work for animations renders, by adding a return statement to addons\flip_fluids_addon\objects\flip_fluid_cache.py line 280

    if vcu.is_blender_281() and cache_object.data.shape_keys is not None:
        for idx,key in enumerate(cache_object.data.shape_keys.key_blocks):
            cache_object.shape_key_remove(key=key)
            return

BUT while rendering blender could randomly crash. Can crash after 10 frames, can render 500 and still going, but seems like more geometry is in cached mesh the more chances it will. Going for debugging blender's src brought me nowhere but to assumption the crash is due to some race condition while setting shape_key vertices data and blender calling notifiers or something like this(crash at any of the v.co assignments in _update_motion_blur()).

The solution for me was to render everything from command line, as described in #1200 JacquesLucke/animation_nodes#1200. I do not believe #1200 is related to my crashes, although looks very similar, but at the end of day it seems like blender -b scene.blend -a renders my sequences just fine and without crashing(so far).

This is not a solution, and maybe not suitable to be here, but google leads here, and maybe this rather dirty hack to make it possible at all(at any cost you can tell) can be helpful.

@rlguy
Copy link
Owner

rlguy commented Feb 22, 2023

My apologies for the ping on this issue thread, just cleaning up the FLIP Fluids GitHub issue tracker.

Motion blur rendering is possible for the FLIP Fluids surface and whitewater particles in Blender 3.1 or later, however there is a currently a bug in Blender (T88811) where command line rendering will be necessary to prevent crashes. More information about motion blur support can be found here: https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Motion-Blur-Support

@rlguy rlguy closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants