BlendLuxCore icon indicating copy to clipboard operation
BlendLuxCore copied to clipboard

Motion Blur doesn't work on collections instances

Open MigCurto opened this issue 2 years ago • 7 comments

Either instances don't show up (if instanced before animation) or motion blur doesnt work if animated after instanced.

.blend file: https://drive.google.com/file/d/1by5KQxPnHEPXMcn67xNstjX7gGBxCcRJ/view?usp=share_link

Steps to reproduce: Create a collection -> Instance to Scene -> animate with keyframes -> turn on motion blur -> render

Screenshots or rendered images: image

Error message from Blender console:

OS: MacOS 12.6.1 Blender version: 3.3.2 LuxCore version: alpha0

MigCurto avatar Jan 21 '23 13:01 MigCurto

@MigCurto Are you still have an issue with recent versions?

odil24 avatar Dec 12 '24 03:12 odil24

Tested on 4.3 , mixed results: instanced with (alt+D) shows motion blur , collections instanced to scene dont show up in render (if using motion blur), not critical I would say, just a limitation.

MigCurto avatar Dec 12 '24 08:12 MigCurto

Tested on 4.3 , mixed results: instanced with (alt+D) shows motion blur , collections instanced to scene dont show up in render (if using motion blur), not critical I would say, just a limitation.

Can you make a new simple test scene with Blender 4.3 and upload here? I will try it too

odil24 avatar Dec 12 '24 10:12 odil24

collection_motion_blur.zip

Here is an AI fixed motion_blur.py file for testing the motion blur.Perhaps some actual developer can take a look at the code and if it is okay, put it into the extension.

motion_blur.zip

Make a backup for old motion_blur.py and replace with new on in - blender/4.2/extensions/user_default/BlendLuxCore/export

I have attached a test file that does not produce correct motion blur without the modified code

EgertKanep avatar Mar 28 '25 11:03 EgertKanep

I've had a quick look at the file @EgertKanep provided.

Only one line actually seems to be necessary to make the provided test scene work, which is the change from

matrix = obj.matrix_world

to

matrix = dg_obj_instance.matrix_world

The AI did two further changes, the first of which seems half-OK (but incomplete) to me, the other rather seems a hallucination to me:

  1. A check in the _append_matrix() function for step != 0 , if the dictionary key already exists. At first glance some form of check seems reasonable, as the code later relies on each item of the dictionary being a list with len(steps) entries, and _append_matrix() is called from inside a try/except block. However, the expected failure point of this doesn't look like it is dependend on the step, so I wouldn't expect the code will ever run into this situation. Furthermore, the reason given by the AI # This can happen if an object was not visible in step 0 but becomes visible later is incomplete as it doesn't account for the object becoming invisible during a later step. Conclusion: I would not merge this as I don't see it being relevant, and if it can be relevant for some scenes, I'd rather find out, have a documented test scene, and understand the issue better from there.

  2. It appends a prefix_modifier = "__LINKED__" to the dictionary keys. Later, it uses this key to skip a check. However, in this process it a) creates a copy of the dictionary entry with a non-prefixed-key without deleting the prefixed-key (duplication for no apparent reason), and b) skipping this check, which is for objects that didn't move in this frame (hence don't require motion blur), seems wrong. Just because an object is linked doesn't imply that it must move. Conclusion: I would not merge this.

Regarding the line I could verify, I will look a bit deeper into the API documentation to verify if this is really a proper solution.

Some further test scenes might be needed. I don't know if there are other combinations for this might be relevant, linked from a second file for example (?)

CodeFHD avatar Mar 28 '25 12:03 CodeFHD

@CodeFHD

I can confirm this works with linked collections as well, that is where I initially tried it.

EgertKanep avatar Mar 28 '25 12:03 EgertKanep

Some progress stored in the following commit, ~~currently in my repo~~ in the official repo since v2.10.0-rc.1: https://github.com/CodeFHD/BlendLuxCore/commit/116ada57e31820e975feee60486606fa25d03045

Besides the issue already described, I noticed that the switch to enable motion blur for a specific object (see image below) was not working for the linked object. It seems to me that it would be better to evaluate the parent so that a more fine-grained control is possible.

Unfortunately this still doesn't seem to fully do it. If I create a copy with alt+D of the monkey on the right, which shows motion blur, then that copy again does not show motion blur, even though they rotate the same. I will continue to investigate.

Image

CodeFHD avatar Mar 30 '25 21:03 CodeFHD