forked from blender/blender
Create possibility to provide render settings via BlenderSceneDelegate #41
@ -21,7 +21,13 @@ class CustomHydraRenderEngine(HydraRenderEngine):
|
|||||||
|
|
||||||
bpy_hydra.register_plugins(["/path/to/plugin")])
|
bpy_hydra.register_plugins(["/path/to/plugin")])
|
||||||
|
|
||||||
def get_delegate_settings(self, engine_type):
|
def get_sync_settings(self, engine_type):
|
||||||
|
|||||||
|
return {
|
||||||
|
'setting1': True,
|
||||||
|
'setting2': "2",
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_render_settings(self, engine_type):
|
||||||
return {
|
return {
|
||||||
'setting1': 1,
|
'setting1': 1,
|
||||||
'setting2': "2",
|
'setting2': "2",
|
||||||
@ -73,18 +79,29 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
def unregister(cls):
|
def unregister(cls):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_delegate_settings(self, engine_type):
|
def get_sync_settings(self, engine_type):
|
||||||
Brian Savery (AMD)
commented
We need explanations of how these methods should be used / overridden We need explanations of how these methods should be used / overridden
|
|||||||
|
return {}
|
||||||
|
|
||||||
|
def get_render_settings(self, engine_type):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# final render
|
# final render
|
||||||
def update(self, data, depsgraph):
|
def update(self, data, depsgraph):
|
||||||
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
|
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
|
||||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.delegate_id)
|
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.delegate_id)
|
||||||
delegate_settings = self.get_delegate_settings(engine_type)
|
|
||||||
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), bpy.context.as_pointer(), delegate_settings)
|
for key, val in self.get_sync_settings(engine_type).items():
|
||||||
|
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
|
||||||
|
|
||||||
|
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), bpy.context.as_pointer())
|
||||||
|
|
||||||
def render(self, depsgraph):
|
def render(self, depsgraph):
|
||||||
if self.engine_ptr:
|
if not self.engine_ptr:
|
||||||
|
return
|
||||||
|
|
||||||
|
for key, val in self.get_render_settings('PREVIEW' if self.is_preview else 'FINAL').items():
|
||||||
|
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
||||||
|
|
||||||
_bpy_hydra.engine_render(self.engine_ptr, depsgraph.as_pointer())
|
_bpy_hydra.engine_render(self.engine_ptr, depsgraph.as_pointer())
|
||||||
|
|
||||||
# viewport render
|
# viewport render
|
||||||
@ -92,8 +109,13 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
if not self.engine_ptr:
|
if not self.engine_ptr:
|
||||||
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), 'VIEWPORT', self.delegate_id)
|
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), 'VIEWPORT', self.delegate_id)
|
||||||
|
|
||||||
delegate_settings = self.get_delegate_settings('VIEWPORT')
|
for key, val in self.get_sync_settings('VIEWPORT').items():
|
||||||
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer(), delegate_settings)
|
_bpy_hydra.engine_set_sync_setting(self.engine_ptr, key, val)
|
||||||
|
|
||||||
|
_bpy_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), context.as_pointer())
|
||||||
|
|
||||||
|
for key, val in self.get_render_settings('VIEWPORT').items():
|
||||||
|
_bpy_hydra.engine_set_render_setting(self.engine_ptr, key, val)
|
||||||
|
|
||||||
def view_draw(self, context, depsgraph):
|
def view_draw(self, context, depsgraph):
|
||||||
if not self.engine_ptr:
|
if not self.engine_ptr:
|
||||||
|
@ -232,7 +232,7 @@ static PyObject *engine_set_sync_setting_func(PyObject * /*self*/, PyObject *arg
|
|||||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||||
engine->set_sync_setting(pxr::TfToken(key), get_setting_val(pyval));
|
engine->set_sync_setting(pxr::TfToken(key), get_setting_val(pyval));
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx: %s", engine, key);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
|
|||||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||||
engine->set_render_setting(pxr::TfToken(key), get_setting_val(pyval));
|
engine->set_render_setting(pxr::TfToken(key), get_setting_val(pyval));
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx: %s", engine, key);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +261,8 @@ static PyMethodDef methods[] = {
|
|||||||
{"engine_sync", engine_sync_func, METH_VARARGS, ""},
|
{"engine_sync", engine_sync_func, METH_VARARGS, ""},
|
||||||
{"engine_render", engine_render_func, METH_VARARGS, ""},
|
{"engine_render", engine_render_func, METH_VARARGS, ""},
|
||||||
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
{"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""},
|
||||||
{"engine_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
||||||
{"engine_render_setting", engine_set_render_setting_func, METH_VARARGS, ""},
|
{"engine_set_render_setting", engine_set_render_setting_func, METH_VARARGS, ""},
|
||||||
|
|
||||||
{NULL, NULL, 0, NULL},
|
{NULL, NULL, 0, NULL},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user
Consider to add a note that these settings refer to keys that Hydra asks.