Arnold Render Support in Blender

This one is a bit out there, and not sure if this is the right place to ask this question, but I’ve been working on getting an Arnold renderer plugin to work with Blender, so far it works, except for the fact the display driver needs to be set up properly and without it, you cannot see buckets rendering images or the IPR from within Blender’s viewport… it’s an update from a couple years ago as the previous build was set up for Arnold 4, I’m working on getting this to work with Arnold 5. You can find the github repo here: Barnold

The issue I’m faced with is this bit here:

def _callback(x, y, width, height, buffer, data):
            #print("+++ _callback:", x, y, width, height, ctypes.cast(buffer, ctypes.c_void_p))
            if buffer:
                    if new_data.poll():
                        #print("+++ _callback: tile", x, y, width, height)
                        _buffer = ctypes.cast(buffer, ctypes.POINTER(ctypes.c_float))
                        a = numpy.ctypeslib.as_array(_buffer, shape=(height, width, 4))
                        rect[y : y + height, x : x + width] = a
            elif not new_data.poll():
            print("+++ _callback: abort")

# Here is where the issue is...
cb = arnold.AtDisplayCallBack(_callback) #AtDisplayCallBack is not an attribute of Arnold
arnold.AiNodeSetPtr(driver, "callback", cb)

I understand this is specific to arnold’s SDK, but have found nothing on their docs discussing this… I was curious if any of you had any idea how I could just rewrite this display callback to work well with blender? It’s essentially the last step to get Arnold to display in both the rendered viewport as Arnold’s IPR and to display buckets while rendering in the UV/Image Editor in Blender.

Many thanks, I know this is a shot in the dark here.

driver_display was removed in Arnold 5, you’ll need to add a custom C/C++ driver.

Thanks for getting back to me, so I would have to implement that in C/C++? No way of doing that in Python?

It needs to be in C/C++.

1 Like

I appreciate your help, I’ll do that then!

If it’s going through C callbacks, you may still be able to do this in plain Python via ctypes:

1 Like

Wow! Nice one, I’ll see if I can give that a shot

I would advise against it, wrapping the Arnold node subclassing API with ctypes is much more complicated than you might expect.


I’ve noticed, thanks! Back to writing the C++ instead, no problem.

Attempting to import that cpp script as is… is something like this the correct way to import the driver?

class ArnoldNodeDisplayDriver(ArnoldNode):
    # No idea what goes here

It’s not a script, you have to compile it as plugin that registers a new node type.

None of this is related to the Blender Python API though.

1 Like

So essentially, blender would have to call node_initialize for example when a user clicks “render” in blender, and fire events/fill parameters to the c++ plugin?

No, the way you would use this is exactly the old driver_display, same mechanism to create the node and set the callback.

I see, and the reason it would work is because when this c++ plugin is compiled and linked to the ai.lib, driver_display_callback would be able to be accessed since this addon is importing arnold, therefore it’s usage would be exactly the same as say driver_png?

Right, it would be available like any other Arnold node once the plugin is loaded.

Nice, and aside from having to manually compile this plugin via visual studio, is there a way that blender can automatically compile this plugin when necessary? I really appreciate your help with this by the way, you’re teaching me a lot about how all of this works.

No, Blender does not include a C++ compiler. You need to set it up separately.

Thanks, so far I’ve got all the dependencies loaded up and linked to the lib file in visual studio, it’s complaining that it can’t find a main() method though when compiling, would you happen to know why that might be?

Update: Changing configuration type to dynamic library appears to fix this error

Hmm… Any ideas? ERROR | node "driver_display_callback" is not installed

Alright, I’m really close now, I finally got:

loading plugins from .
 driver_display_callback          driver

When I do this command:
kick -l C:\Users\tyler\source\repos\driver_display_callback\x64\Release -nodes

But when I render a scene in Blender, it just keeps saying ERROR | node "driver_display_callback" is not installed

Any idea what I should do next? Thanks.