forked from blender/blender
Fixed rendering for MacOS #82
@ -7,6 +7,7 @@ USD Hydra Based Renderer
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
class CustomHydraRenderEngine(bpy.types.HydraRenderEngine):
|
class CustomHydraRenderEngine(bpy.types.HydraRenderEngine):
|
||||||
# Identifier and name in the user interface.
|
# Identifier and name in the user interface.
|
||||||
bl_idname = "CUSTOM_HYDRA_RENDERER"
|
bl_idname = "CUSTOM_HYDRA_RENDERER"
|
||||||
@ -53,8 +54,10 @@ class CustomHydraRenderEngine(bpy.types.HydraRenderEngine):
|
|||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(CustomHydraRenderEngine)
|
bpy.utils.register_class(CustomHydraRenderEngine)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_class(CustomHydraRenderEngine)
|
bpy.utils.unregister_class(CustomHydraRenderEngine)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
@ -4,6 +4,7 @@ __all__ = (
|
|||||||
"export_mtlx",
|
"export_mtlx",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def export_mtlx(material):
|
def export_mtlx(material):
|
||||||
""" Exports material to .mtlx file. It is called from Blender source code. """
|
""" Exports material to .mtlx file. It is called from Blender source code. """
|
||||||
try:
|
try:
|
||||||
|
@ -55,11 +55,7 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
|||||||
free_camera_delegate_ = std::make_unique<pxr::HdxFreeCameraSceneDelegate>(
|
free_camera_delegate_ = std::make_unique<pxr::HdxFreeCameraSceneDelegate>(
|
||||||
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("freeCamera"));
|
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("freeCamera"));
|
||||||
|
|
||||||
#ifdef __APPLE__
|
if (bl_engine->type->flag & RE_USE_GPU_CONTEXT && GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
|
||||||
render_task_delegate_ = std::make_unique<RenderTaskDelegate>(
|
|
||||||
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
|
|
||||||
#else
|
|
||||||
if (bl_engine->type->flag & RE_USE_GPU_CONTEXT) {
|
|
||||||
render_task_delegate_ = std::make_unique<GPURenderTaskDelegate>(
|
render_task_delegate_ = std::make_unique<GPURenderTaskDelegate>(
|
||||||
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
|
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
|
||||||
}
|
}
|
||||||
@ -67,7 +63,6 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
|||||||
render_task_delegate_ = std::make_unique<RenderTaskDelegate>(
|
render_task_delegate_ = std::make_unique<RenderTaskDelegate>(
|
||||||
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
|
render_index_.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
render_task_delegate_->set_camera(free_camera_delegate_->GetCameraId());
|
render_task_delegate_->set_camera(free_camera_delegate_->GetCameraId());
|
||||||
|
|
||||||
if (render_delegate_name_ == "HdStormRendererPlugin") {
|
if (render_delegate_name_ == "HdStormRendererPlugin") {
|
||||||
|
@ -36,7 +36,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderEngine *bl_engine = pyrna_to_pointer<RenderEngine>(pyengine, &RNA_RenderEngine);
|
RenderEngine *bl_engine = pyrna_to_pointer<RenderEngine>(pyengine, &RNA_RenderEngine);
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %s", engine_type);
|
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %s", engine_type);
|
||||||
Engine *engine = nullptr;
|
Engine *engine = nullptr;
|
||||||
try {
|
try {
|
||||||
@ -53,7 +53,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
|||||||
catch (std::runtime_error &e) {
|
catch (std::runtime_error &e) {
|
||||||
CLOG_ERROR(LOG_RENDER_HYDRA, "%s", e.what());
|
CLOG_ERROR(LOG_RENDER_HYDRA, "%s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p", engine);
|
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p", engine);
|
||||||
return PyLong_FromVoidPtr(engine);
|
return PyLong_FromVoidPtr(engine);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, float *data)
|
|||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxr::HdFormat format = buffer->GetFormat();
|
pxr::HdFormat format = buffer->GetFormat();
|
||||||
size_t len = buffer->GetWidth() * buffer->GetHeight() * pxr::HdGetComponentCount(format);
|
size_t len = buffer->GetWidth() * buffer->GetHeight() * pxr::HdGetComponentCount(format);
|
||||||
if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat32) {
|
if (pxr::HdGetComponentFormat(format) == pxr::HdFormatFloat32) {
|
||||||
|
Loading…
Reference in New Issue
Block a user