Render: support USD Hydra render delegates
Hydra is a rendering architecture part of USD, designed to abstract the host application from the renderer. A renderer implementing a Hydra render delegate can run in any host application supporting Hydra, which now includes Blender. For external renderers this means less code to be written, and improved performance due to a using a C++ API instead of a Python API. Add-ons need to subclass bpy.types.HydraRenderEngine. See the example in the Python API docs for details. An add-on for Hydra Storm will be included as well. This is USD's rasterizing renderer, used in other applications like usdview. For users it can provide a preview of USD file export, and for developers it serves a reference. There are still limitations and missing features, especially around materials. The remaining to do items are tracked in #110765. This feature was contributed by AMD. Ref #110765 Co-authored-by: Georgiy Markelov <georgiy.m.markelov@gmail.com> Co-authored-by: Vasyl-Pidhirskyi <vpidhirskyi@gmail.com> Co-authored-by: Brian Savery <brian.savery@gmail.com> Co-authored-by: Brecht Van Lommel <brecht@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/104712
This commit is contained in:
committed by
Brecht Van Lommel
parent
61f407d427
commit
04bb5f9995
57
doc/python_api/examples/bpy.types.HydraRenderEngine.py
Normal file
57
doc/python_api/examples/bpy.types.HydraRenderEngine.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Base class for integrating USD Hydra based renderers.
|
||||
|
||||
USD Hydra Based Renderer
|
||||
++++++++++++++++++++++++
|
||||
"""
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
class CustomHydraRenderEngine(bpy.types.HydraRenderEngine):
|
||||
# Identifier and name in the user interface.
|
||||
bl_idname = "CUSTOM_HYDRA_RENDERER"
|
||||
bl_label = "Custom Hydra Renderer"
|
||||
|
||||
# Name of the render plugin.
|
||||
bl_delegate_id = "HdCustomRendererPlugin"
|
||||
|
||||
# Register path to plugin.
|
||||
@classmethod
|
||||
def register(cls):
|
||||
super().register()
|
||||
|
||||
import pxr
|
||||
pxr.Plug.Registry().RegisterPlugins(['/path/to/plugin'])
|
||||
|
||||
# Render settings that will be passed to the delegate.
|
||||
def get_render_settings(self, engine_type):
|
||||
return {
|
||||
'myBoolean': True,
|
||||
'myValue': 8,
|
||||
'aovToken:Depth': "depth",
|
||||
}
|
||||
|
||||
# RenderEngine methods for update, render and draw are implemented in
|
||||
# HydraRenderEngine. Optionally extra work can be done before or after
|
||||
# by implementing the methods like this.
|
||||
def update(self, data, depsgraph):
|
||||
super().update(data, depsgraph)
|
||||
# Do extra work here
|
||||
|
||||
def update_render_passes(self, scene, render_layer):
|
||||
if render_layer.use_pass_z:
|
||||
self.register_pass(scene, render_layer, 'Depth', 1, 'Z', 'VALUE')
|
||||
|
||||
|
||||
# Registration
|
||||
def register():
|
||||
bpy.utils.register_class(CustomHydraRenderEngine)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(CustomHydraRenderEngine)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
Reference in New Issue
Block a user