neverhood311 / Stop-motion-OBJ

A Blender add-on for importing a sequence of OBJ meshes as frames
GNU General Public License v3.0
681 stars 52 forks source link

Rendering doesnt wait for sequence streaming to load #123

Open ThomasSchumacher77 opened 3 years ago

ThomasSchumacher77 commented 3 years ago

System Information Operating system: Kubuntu 18.10

Addon version Broken: 2.1.0 Worked:

Describe the bug Fantastic AddOn! I used it successfully to visualize transient CFD results. However, I am now running into the following issue: I have a PLY sequence with individual files being quite large (~300MB). The sequence is over 400 files long. So I chose the streaming option. Stream while playback is ticked. And when I manually select the frame/time the Addon loads the required PLY file. Load time are quite long, several minutes per PLY file. When I start the animation rendering, it does not load new PLY to cache. Error:

_Saved: '/tmp/0001.png' Time: 00:04.71 (Saving: 00:00.30)

Saved: '/tmp/0002.png' Time: 00:04.68 (Saving: 00:00.30)

Python: Traceback (most recent call last): File "/home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/addons/io_mesh_ply/init.py", line 87, in execute context.window.cursor_set('WAIT') AttributeError: 'NoneType' object has no attribute 'cursor_set'

location: /home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/modules/bpy/ops.py:132 Error: Python: Traceback (most recent call last): File "/home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/addons/io_mesh_ply/init.py", line 87, in execute context.window.cursor_set('WAIT') AttributeError: 'NoneType' object has no attribute 'cursor_set'

location: /home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/modules/bpy/ops.py:132

Traceback (most recent call last): File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 70, in updateFrame setFrameNumber(scn.frame_current) File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 612, in setFrameNumber setFrameObjStreamed(obj, frameNum, forceLoad=forceMeshLoad, deleteMaterials=not mss.perFrameMaterial) File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 685, in setFrameObjStreamed importStreamedFile(obj, idx) File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 731, in importStreamedFile mss.fileImporter.load(mss.fileFormat, filename) File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 238, in load self.loadPLY(filePath) File "/home/thomas/.config/blender/2.91/scripts/addons/Stop-motion-OBJ/stop_motion_obj.py", line 267, in loadPLY bpy.ops.import_mesh.ply(filepath=filePath) File "/home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/modules/bpy/ops.py", line 132, in call ret = _op_call(self.idname_py(), None, kw) RuntimeError: Error: Python: Traceback (most recent call last): File "/home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/addons/io_mesh_ply/init.py", line 87, in execute context.window.cursor_set('WAIT') AttributeError: 'NoneType' object has no attribute 'cursor_set'

location: /home/thomas/Software/blender-2.91.0-linux64/2.91/scripts/modules/bpy/ops.py:132

Saved: '/tmp/0003.png' Time: 00:05.00 (Saving: 00:00.30)_

To clarify, PLY files 1 and 2 I loaded "manually" into the cache, by selecting the time in the workbench. It rendered those two frames ok. However, it seems the renderer races ahead to time 3 without waiting for the time 3 PLY to be loaded. The renderer keeps using the PLY file from time 2 for all subsequent frames.

It works fine with smaller PLY files, so I guess no easy way to reproduce.

Regards Thomas

neverhood311 commented 3 years ago

First of all, thank you for providing the error message. That's really helpful.

Quick questions: Which version of Blender are you using? Are you able to install different versions of Blender if required? Are you rendering via the UI or via the command line?

ThomasSchumacher77 commented 3 years ago

Hi, Blender 2.91.0 Yes. I can install other version of Blender. No problem. I am rendering through the UI. Would have to read up on command line.

Thanks for the fast response.

Regards Thomas

neverhood311 commented 3 years ago

You might want to try Blender 2.83.12 LTS. It seems to be a little more stable than 2.91.x in some circumstances.

I'm going to look into that error message and see if the PLY importer changed from 2.83 to 2.91.

Also, if possible, you might want to try .obj or .stl. But I understand that could be a lot of work if not impossible.

ThomasSchumacher77 commented 3 years ago

Looks like WillemKauf ran into the same issue. I tried 2.83.12 LTS. A first test seems to run ok. Thanks for the hint!

neverhood311 commented 3 years ago

I think this is a problem with the PLY importer. I've just filed a bug with Blender: https://developer.blender.org/T85770

fractalgrower-p0 commented 3 years ago

Hello @neverhood311,

I just wanted to write that this problem also occurred to me. I am using Blender 2.93 alpha.

qdouasbin commented 2 years ago

Hi.

I have the same error with blender 3.0.1. I also tried Blender 3.2.0, compile directly from the git sources and the same error message and behavior.

Can you pleasse point me towards a workaround or a place in the code to implement a correction? If that works for me I could do a merge request to fix this.

Thank you.

qdouasbin commented 2 years ago

Just in case it helps someone in the future with the same error: I created a small python script as a workaround to this bug. It simply loops over the frame and outputs the frames one by one.

That fixes the problem in my case.

import bpy

# Constants
NUMBER_OF_FRAMES = bpy.context.scene.frame_end - bpy.context.scene.frame_start

# prefix for img
IMG_PREFIX = bpy.context.scene.render.filepath

for frame_idx in range(NUMBER_OF_FRAMES+1):
    print(" > Render frame %08d out of %08d" % (frame_idx+ 1, NUMBER_OF_FRAMES+1))
    # Set correct frame
    bpy.context.scene.frame_current = bpy.context.scene.frame_start + frame_idx

    # Set name of output
    bpy.context.scene.render.filepath = IMG_PREFIX + '_%08d' % bpy.context.scene.frame_current

    # Render
    bpy.ops.render.render(write_still=True)

# Get everything back to normal    
bpy.context.scene.render.filepath = IMG_PREFIX

You just have to load it in the Text Editor of the "Scripting" tab and press play.

Hope this helps!

neverhood311 commented 1 year ago

Looks like the PLY I/O addon is being replaced by a new native PLY importer in Blender 4.0 (see here, which means this bug will be irrelevant in the new major version. There might still be something to be done for the 3.6 version