bcongdon / bpy_lambda

🎥 A compiled binary of Blender-as-a-Python-Module (bpy) for use in AWS Lambda
MIT License
66 stars 22 forks source link

Missing remesh operation #12

Open HCAWN opened 5 years ago

HCAWN commented 5 years ago

I am aware that some things have been stripped out such as FFMPEG. However unlike FFMPEG, when calling bpy.ops.object.modifier_add(type='REMESH') no error is returned, meaning it took a while to figure out why the below script wasn't working:

bpy.ops.object.modifier_add(type='REMESH')
bpy.context.object.modifiers["Remesh"].octree_depth = 6
bpy.context.object.modifiers["Remesh"].scale = 0.9
bpy.context.object.modifiers["Remesh"].threshold = 1
bpy.context.object.modifiers["Remesh"].sharpness = 0
bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh")

Is there a specific reason for omitting Remesh or was it just caught up in the cull? Is there a better way for dealing with missing operations in case other people get caught out?

Many thanks, H

bcongdon commented 5 years ago

I wish I had better information, but I really don't know why that operation would silently fail... 😞

Possibly, whatever "remesh" is doing relies on some library that isn't loaded.

QuteBits commented 5 years ago

Dockerfile contains -DWITH_MOD_REMESH=OFF \ and remesh function has a check in the code that looks at the build flags, failing silently if remesh wasn't built in.

QuteBits commented 5 years ago

Actually it would be really convenient if remesh would be included into the default build as it's one of the fundamental bpy operations. Do you think you could add it to the default build? Or is it a bad idea for some reason?

bcongdon commented 5 years ago

Ah, good find @QuteBits. 👍

It'd be great if we could enable that flag. I don't think I'll have the bandwidth to do it in the coming week(s), but if you want to experiment with it and make a PR, that'd be awesome.

Otherwise, I'll add it to my backlog of things to try

HCAWN commented 4 years ago

Hi @bcongdon I'm still really keen to have this as is @QuteBits it seems. Do you think you'd be able to find the time over the next few weeks at all? I'd also be happy to remunerate you if that would help haha

bcongdon commented 4 years ago

I can take another look. Could you send me what you'd expect the output of bpy.ops.object.modifier_apply to be? (i.e. to make sure that remesh is working, and not silently failing)

HCAWN commented 4 years ago

Great thank you! If you change 6 to 1 on bpy.context.object.modifiers["Remesh"].octree_depth = 6 Then the output mesh will have a significantly lower number of vertices than the input. If it fails then the mesh will be the same. You could run print(len(bpy.context.object.data.vertices)) before and after to see if it's changed

HCAWN commented 4 years ago

output should be: >>>482 >>>8 if it fails I imagine: >>>482 >>>482


bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
bpy.ops.mesh.primitive_uv_sphere_add()
print(len(bpy.context.object.data.vertices))
bpy.ops.object.modifier_add(type='REMESH')
bpy.context.object.modifiers["Remesh"].octree_depth = 1
bpy.context.object.modifiers["Remesh"].scale = 0.9
bpy.context.object.modifiers["Remesh"].threshold = 1
bpy.context.object.modifiers["Remesh"].sharpness = 0
bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh")
print(len(bpy.context.object.data.vertices))```
bcongdon commented 4 years ago

Thanks! That's very helpful. I just pushed a commit to master that flips on the remesh operation, and it seems to pass the condition you describe.

Can you try it out before I push out a new release?

QuteBits commented 4 years ago

hello - just tried to build a new release off master. It seemed to compile and all tests seemed to pass. When I try to use it, it instantly fails on something that seems one of its basic operations that should be in the build:

image

I assume that something simply went wrong when building it. Could you please make a new release off of master in the same way you did previous releases so that I could compare both?

QuteBits commented 4 years ago

hello again - could you please build a new release from master? I tried to build the whole thing against a fresh EC2 instance again and my build doesn't work despite compiling (and, well, just from taking a look at the amount of things it depends on, it seems to be a lot of work to debug what went wrong during the compilation time).

bcongdon commented 4 years ago

Just pushed a new release, let me know if that works for you

QuteBits commented 4 years ago

ahh, so great - as I'm recompiling the whole thing manually on an EC2 instance for the last 6 hours, going through each line from the docker image 1-by-1 :) let me have a quick look at the release you just pushed.

QuteBits commented 4 years ago

somehow it leaves me with this error right at the start of our scripts: image

QuteBits commented 4 years ago

could it be that it also failed silently somewhere while you were compiling it? For me, running python test.py after the build was finished, failed too - does it work/fail on your side?

bcongdon commented 4 years ago

What happens if you run test.sh? I'm not getting any failures on a clean build.

When you tried to recreate the build on EC2, were you using amazonlinux? The docker build uses amazonlinux version 2017.03 -- I don't know what the compatability is like with newer versions, but I'm pretty confident that if you're using a linux distro that isn't amazonlinux, you'll probably run into issues running the resulting build artifacts on lambda.

QuteBits commented 4 years ago

Thank you for a quick response.

I did it on 2018.03 one (as 2017.03 was not on their OS list anymore when creating new EC2 instances) and when building against it, lots of commands from Dockerfile didn't run unless I added sudo in front of them. Also, this:

image

I will try to find 2017.03 and compile bpy against it. Could you please, if you find some free time, try to build a release against 2018.03 too?

bcongdon commented 4 years ago

Sure, I'll try out a build tomorrow.

QuteBits commented 4 years ago

:) thank you

bcongdon commented 4 years ago

Just published v1.3.1, which was built against amazonlinux:2018.03

QuteBits commented 4 years ago

awesome, will try in a second

QuteBits commented 4 years ago

hmm, it still shows the same error as before: image I will take a look if it's not importing it correctly or something. I'm still using python 3.6 on my functions (other runtimes: python 3.7 results in segmentation fault, python 3.8 in some libGL error)

bcongdon commented 4 years ago

Hmm... Well, I'm sorry it's still not working 😞 I'll take a look and see if I can reproduce your error on different versions of Python on Monday.

I've also been meaning to update this package to Blender 2.8 at some point, maybe that would fix the issue 🤷‍♂