I'm trying to speed up a script that has to generate a black and transparent object (those are the only two RGBA colors), and use the pixel data coming from pictures of it shot from multiple angles. At the moment I'm using Blender Internal to render the whole scene for every position and then reload the saved images inside PIL to use the pixel data.

I would like to avoid having to save every image just to use said data.

I found out that:

  • rendering without write_still=True is not useful to me, since I can't access the rendered image or its data without saving it to a filepath;

  • using nodes set up a Viewer Node is currently useless, since the script will run in background mode (see this, this, and this I can't do);

  • baking doesn't seem to work either.

I think baking might be the way, but my code isn't outputting a different render for every camera position. What I'm doing is:

# setup image to bake to
bpy.data.images.new('test', 500, 500, alpha=True)

# uvm in my code is an existing uvm, but this works as an example
uvm = bpy.data.objects['Plane'].data.uv_textures['uvmPlane']

# unwrap test on the uv layer
for d in uvm.data:
    d.image = D.images['test']

# setup baking and bake
bpy.data.scenes['Scene'].render.bake_type = 'FULL'

The output is the same transparent and black texture that exists on the Plane object, regardless of the camera position.

  • 1
    $\begingroup$ Hi, I'm trying to accomplish a similar thing, and so far I have it (kind of) working if you keep the resolution exactly at 512 by 256: blender.stackexchange.com/questions/128174/… but now I'm (and looking for people to try to help) optimize it to get it at any resolution $\endgroup$ – bluejayke Jan 10 '19 at 22:09
  • $\begingroup$ It seems like theres no info regarding this on here, although there are various questions about it $\endgroup$ – bluejayke Jan 10 '19 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.