diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-08 12:08:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-08 12:35:32 +0300 |
commit | 37a2a3c8dcf800ba87cbf82f374ceda1c01ebde2 (patch) | |
tree | 58406923ffa95ab2aa2abf841a9d3c85eda70cbd /doc/python_api/examples/bpy.types.RenderEngine.py | |
parent | d8163a08fb62903257878ae1bdbb3c0ba5b8e773 (diff) |
Fix RenderEngine API docs
Correct access to passes, D1779 by @levon.
Also use is_preview attr and use register/unregister functions.
Diffstat (limited to 'doc/python_api/examples/bpy.types.RenderEngine.py')
-rw-r--r-- | doc/python_api/examples/bpy.types.RenderEngine.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/doc/python_api/examples/bpy.types.RenderEngine.py b/doc/python_api/examples/bpy.types.RenderEngine.py index 7af7de1068c..efb7640bcc7 100644 --- a/doc/python_api/examples/bpy.types.RenderEngine.py +++ b/doc/python_api/examples/bpy.types.RenderEngine.py @@ -9,8 +9,8 @@ import bpy class CustomRenderEngine(bpy.types.RenderEngine): # These three members are used by blender to set up the # RenderEngine; define its internal name, visible name and capabilities. - bl_idname = 'custom_renderer' - bl_label = 'Flat Color Renderer' + bl_idname = "custom_renderer" + bl_label = "Flat Color Renderer" bl_use_preview = True # This is the only method called by blender, in this example @@ -21,7 +21,7 @@ class CustomRenderEngine(bpy.types.RenderEngine): self.size_x = int(scene.render.resolution_x * scale) self.size_y = int(scene.render.resolution_y * scale) - if scene.name == 'preview': + if self.is_preview: self.render_preview(scene) else: self.render_scene(scene) @@ -36,7 +36,7 @@ class CustomRenderEngine(bpy.types.RenderEngine): # Here we write the pixel values to the RenderResult result = self.begin_result(0, 0, self.size_x, self.size_y) - layer = result.layers[0] + layer = result.layers[0].passes["Combined"] layer.rect = green_rect self.end_result(result) @@ -50,21 +50,37 @@ class CustomRenderEngine(bpy.types.RenderEngine): # Here we write the pixel values to the RenderResult result = self.begin_result(0, 0, self.size_x, self.size_y) - layer = result.layers[0] + layer = result.layers[0].passes["Combined"] layer.rect = blue_rect self.end_result(result) -# Register the RenderEngine -bpy.utils.register_class(CustomRenderEngine) -# RenderEngines also need to tell UI Panels that they are compatible -# Otherwise most of the UI will be empty when the engine is selected. -# In this example, we need to see the main render image button and -# the material preview panel. -from bl_ui import properties_render -properties_render.RENDER_PT_render.COMPAT_ENGINES.add('custom_renderer') -del properties_render +def register(): + # Register the RenderEngine + bpy.utils.register_class(CustomRenderEngine) -from bl_ui import properties_material -properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add('custom_renderer') -del properties_material + # RenderEngines also need to tell UI Panels that they are compatible + # Otherwise most of the UI will be empty when the engine is selected. + # In this example, we need to see the main render image button and + # the material preview panel. + from bl_ui import ( + properties_render, + properties_material, + ) + properties_render.RENDER_PT_render.COMPAT_ENGINES.add(CustomRenderEngine.bl_idname) + properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add(CustomRenderEngine.bl_idname) + + +def unregister(): + bpy.utils.unregister_class(CustomRenderEngine) + + from bl_ui import ( + properties_render, + properties_material, + ) + properties_render.RENDER_PT_render.COMPAT_ENGINES.remove(CustomRenderEngine.bl_idname) + properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.remove(CustomRenderEngine.bl_idname) + + +if __name__ == "__main__": + register() |