# Low poly to high poly instancing

Is there a way to connect a low poly object with a high poly object linked from another blend file, that is only interchanged on rendering?

Example: In the viewport I have my low_cube.001. It is connected somehow to high_cube.001 in the high_cube.blend. In the viewport there will always be low_cube.001. On rendering the scene with Cycles, there should be high_cube.001 only.

Is there an "artists" way? If not, is there a way I can interchange objects with Python, somehow transfer the high poly object into the render engine?

EDIT: Regarding Python, I don't need a finished piece of code completely worked out, just some directions or ideas would be great alreay!

• do you need to change at render time or before ? – Chebhou Mar 18 '15 at 9:34
• Only at render time! – bortran Mar 18 '15 at 11:06

With a python script you could add handlers to

bpy.app.handlers.render_init API Reference
bpy.app.handlers.render_complete API Reference

and then search through all selectable objects in the 3D view replacing them with a high poly version if one is found.

bpy.context.selectable_objects API Reference
bpy.data.objects API Reference

You could find a matching object (by name in the format you described) with code similar to the example provided

def findHighPoly(obj):
if obj.name[:3] == "low":
for o in bpy.data.objects:
if o.name[:4] == "high" and o.name[4:] == obj.name[3:]:
return o
else:
return null


Notes:

• bpy.context.selectable_object might not be the best fit for you.
• It might be better (consider you'll be switching back after rendering) to store the relationships you find inside of an array.
• If the handlers don't work, you could always make some operators along with some hotkeys to trigger the low > high poly and high > low poly transition.
• That's a pretty good solution already and actually the way I was thinking about, However, would it be possible to interchange objects without bringing them into the viewport, like compiling BVH myself or alike? I know that's pretty sophisticated stuff, still I'd like to know if it would be possible at least in theory. – bortran Mar 18 '15 at 19:14
• I'm not all that familiar with cycles. From what I've just looked up though, yes, it should be possible. Your best bet at that point would be to look at either the python that interfaces with cycles and see if you can sneak in something there or you'd have to modify the application code. It definitely wouldn't be pretty though. – Coburn Mar 18 '15 at 19:20
• If you had another lead where begin looking for, that would be great. Apart from that, this works pretty well, but render_init as well as render_pre doesn't wait for python to finish it's job. That's a big bummer. But you kinda anticipated that when suggesting hotkeys, didn't you? – bortran Mar 19 '15 at 18:48
• Yeah, I've had some problems when working with some of the other handlers in the past. Also make sure that you're using the bpy.app.handlers.persistent [ blender.org/api/blender_python_api_2_74_0/… ] if you're loading new files so it doesn't clear your handler. Otherwise it's just the nature of the handlers I guess :c – Coburn Mar 19 '15 at 18:54

A method often used for rigged characters is to setup two groups, one containing the low-res objects and another containing the hi-res objects.

When linking a model from another blend file you select the group and Dupli-Group will be used, with a simple switch between low and hi res being made in the Duplication settings of the object properties. This method can swap the many related objects belonging to a group all in one go.

You could setup a pre and post render handler to swap these groups automatically.

bpy.context.object.dupli_group = bpy.data.groups["quadbot_bridge_lo"]


To experiment and learn how this works you could try the CGCookie FlexRig which uses this technique. This was also used in Sintel and Tears of Steal if you have a copy of those data files.

one way is to switch the data block this will link : V groups, V color, material, UV maps ..; but it will reserve the modifiers, constraints Loc,Rot,Scale and animation

• Well, either I don't understand it correctly or that doesn't solve the problem. If I change the linked mesh data to another (highpoly) object, it's immediatly interchanged with the other object in the viewport. – bortran Mar 18 '15 at 11:08
• @bortran yes the change is immediate , does this work for you if it's triggered on render time ? – Chebhou Mar 18 '15 at 18:11
• Depends I guess. If I have to trigger it at render time with Python I'd rather exchange objects completely instead of relinking the mesh data. However if your way was possible without Python to exchange at render time, that would be great also, and I think a lot of people then would like to know, how it worked. – bortran Mar 18 '15 at 19:19

The Visibility toggles for viewport and rendering allow you to control the resolution of a model based on what you see on the screen vs. what will be rendered.

You can click on or drag across the camera and eye icons to enable/disable visibility of Modifiers.

For the Subdivision and Multi-res Modifiers, there are also controls for changing what subdivision level will be used for either of the view modes.

To add to @sambler's answer, you can also link both the high poly and low poly versions and, using a rig proxy on the low poly version, animate whatever you like. Just hide the render layer of the low poly and hide the high poly version in the viewport.