RenderEngine(bpy_struct)

Simple Render Engine

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_use_preview = True

    # This is the only method called by blender, in this example
    # we use it to detect preview rendering and call the implementation
    # in another method.
    def render(self, scene):
        scale = scene.render.resolution_percentage / 100.0
        self.size_x = int(scene.render.resolution_x * scale)
        self.size_y = int(scene.render.resolution_y * scale)

        if scene.name == 'preview':
            self.render_preview(scene)
        else:
            self.render_scene(scene)

    # In this example, we fill the preview renders with a flat green color.
    def render_preview(self, scene):
        pixel_count = self.size_x * self.size_y

        # The framebuffer is defined as a list of pixels, each pixel
        # itself being a list of R,G,B,A values
        green_rect = [[0.0, 1.0, 0.0, 1.0]] * pixel_count

        # 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.rect = green_rect
        self.end_result(result)

    # In this example, we fill the full renders with a flat blue color.
    def render_scene(self, scene):
        pixel_count = self.size_x * self.size_y

        # The framebuffer is defined as a list of pixels, each pixel
        # itself being a list of R,G,B,A values
        blue_rect = [[0.0, 0.0, 1.0, 1.0]] * pixel_count

        # 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.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

from bl_ui import properties_material
properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add('custom_renderer')
del properties_material

base class — bpy_struct

subclasses — CYCLES

class bpy.types.RenderEngine(bpy_struct)

Render engine

bl_idname
Type :string, default “”, (never None)
bl_label
Type :string, default “”, (never None)
bl_use_postprocess
Type :boolean, default False
bl_use_preview
Type :boolean, default False
bl_use_shading_nodes
Type :boolean, default False
camera_override
Type :Object, (readonly)
is_animation
Type :boolean, default False
is_preview
Type :boolean, default False
resolution_x
Type :int in [-inf, inf], default 0, (readonly)
resolution_y
Type :int in [-inf, inf], default 0, (readonly)
tile_x
Type :int in [0, inf], default 0
tile_y
Type :int in [0, inf], default 0
use_highlight_tiles
Type :boolean, default False
update(data=None, scene=None)

Export scene data for render

render(scene=None)

Render scene into an image

view_update(context=None)

Update on data changes for viewport render

view_draw(context=None)

Draw viewport render

update_script_node(node=None)

Request update call for viewport rendering

tag_redraw()

tag_redraw

tag_update()

tag_update

begin_result(x, y, w, h, layer="")

begin_result

Parameters:
  • x (int in [0, inf]) – X
  • y (int in [0, inf]) – Y
  • w (int in [0, inf]) – Width
  • h (int in [0, inf]) – Height
  • layer (string, (optional, never None)) – Layer, Single layer to get render result for
Returns:

Result

Return type:

RenderResult

update_result(result)

update_result

Parameters:result (RenderResult) – Result
end_result(result, cancel=False)

end_result

Parameters:
  • result (RenderResult) – Result
  • cancel (boolean, (optional)) – Cancel, Don’t merge back results
test_break()

test_break

Returns:Break
Return type:boolean
update_stats(stats, info)

update_stats

Parameters:
  • stats (string, (never None)) – Stats
  • info (string, (never None)) – Info
update_progress(progress)

update_progress

Parameters:progress (float in [0, 1]) – Percentage of render that’s done
update_memory_stats(memory_used=0.0, memory_peak=0.0)

update_memory_stats

Parameters:
  • memory_used (float in [0, inf], (optional)) – Current memory usage in megabytes
  • memory_peak (float in [0, inf], (optional)) – Peak memory usage in megabytes
report(type, message)

report

Parameters:
  • type (enum set in {‘DEBUG’, ‘INFO’, ‘OPERATOR’, ‘PROPERTY’, ‘WARNING’, ‘ERROR’, ‘ERROR_INVALID_INPUT’, ‘ERROR_INVALID_CONTEXT’, ‘ERROR_OUT_OF_MEMORY’}) – Type
  • message (string, (never None)) – Report Message

Inherited Properties

Inherited Functions

Table Of Contents

Previous topic

RemeshModifier(Modifier)

Next topic

RenderLayer(bpy_struct)