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 self.is_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].passes["Combined"]
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].passes["Combined"]
layer.rect = blue_rect
self.end_result(result)
def register():
# 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_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()
base class — bpy_struct
-
class
bpy.types.
RenderEngine
(bpy_struct)¶ Render engine
-
bl_idname
¶ Type: string, default “”, (never None)
-
bl_label
¶ Type: string, default “”, (never None)
-
bl_use_exclude_layers
¶ Type: boolean, default False
-
bl_use_postprocess
¶ Type: boolean, default False
-
bl_use_preview
¶ Type: boolean, default False
-
bl_use_save_buffers
¶ Type: boolean, default False
-
bl_use_shading_nodes
¶ Type: boolean, default False
-
bl_use_shading_nodes_custom
¶ Type: boolean, default True
-
bl_use_spherical_stereo
¶ Type: boolean, default False
-
bl_use_texture_preview
¶ Type: boolean, default False
-
is_animation
¶ Type: boolean, default False
-
is_preview
¶ Type: boolean, default False
-
layer_override
¶ Type: boolean array of 20 items, default (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
-
render
¶ Type: RenderSettings
, (readonly)
-
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
-
bake
(scene, object, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)¶ Bake passes
Parameters: - pass_type (enum in ['COMBINED', 'AO', 'SHADOW', 'NORMAL', 'UV', 'ROUGHNESS', 'EMIT', 'ENVIRONMENT', 'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE']) – Pass, Pass to bake
- pass_filter (int in [0, inf]) – Pass Filter, Filter to combined, diffuse, glossy, transmission and subsurface passes
- object_id (int in [0, inf]) – Object Id, Id of the current object being baked in relation to the others
- num_pixels (int in [0, inf]) – Number of Pixels, Size of the baking batch
- depth (int in [0, inf]) – Pixels depth, Number of channels
-
view_update
(context=None)¶ Update on data changes for viewport render
-
view_draw
(context=None)¶ Draw viewport render
-
update_script_node
(node=None)¶ Compile shader script node
-
tag_redraw
()¶ Request redraw for viewport rendering
-
tag_update
()¶ Request update call for viewport rendering
-
update_render_passes
(scene=None, renderlayer=None)¶ Update the render passes that will be generated
-
begin_result
(x, y, w, h, layer="", view="")¶ Create render result to write linear floating point render layers and passes
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
- view (string, (optional, never None)) – View, Single view to get render result for
Returns: Result
Return type:
-
update_result
(result)¶ Signal that pixels have been updated and can be redrawn in the user interface
Parameters: result ( RenderResult
) – Result
-
end_result
(result, cancel=False, highlight=False, do_merge_results=False)¶ All pixels in the render result have been set and are final
Parameters: - result (
RenderResult
) – Result - cancel (boolean, (optional)) – Cancel, Don’t mark tile as done, don’t merge results unless forced
- highlight (boolean, (optional)) – Highlight, Don’t mark tile as done yet
- do_merge_results (boolean, (optional)) – Merge Results, Merge results even if cancel=true
- result (
-
add_pass
(name, channels, chan_id, layer="")¶ Add a pass to the render layer
Parameters: - name (string, (never None)) – Name, Name of the Pass, without view or channel tag
- channels (int in [0, inf]) – Channels
- chan_id (string, (never None)) – Channel IDs, Channel names, one character per channel
- layer (string, (optional, never None)) – Layer, Single layer to add render pass to
-
get_result
()¶ Get final result for non-pixel operations
Returns: Result Return type: RenderResult
-
test_break
()¶ Test if the render operation should been canceled, this is a fast call that should be used regularly for responsiveness
Returns: Break Return type: boolean
-
active_view_get
()¶ active_view_get
Returns: View, Single view active Return type: string, (never None)
-
active_view_set
(view)¶ active_view_set
Parameters: view (string, (never None)) – View, Single view to set as active
-
camera_shift_x
(camera, use_spherical_stereo=False)¶ camera_shift_x
Parameters: use_spherical_stereo (boolean, (optional)) – Spherical Stereo Returns: Shift X Return type: float in [0, inf]
-
camera_model_matrix
(camera, use_spherical_stereo=False)¶ camera_model_matrix
Parameters: use_spherical_stereo (boolean, (optional)) – Spherical Stereo Returns: Model Matrix, Normalized camera model matrix Return type: float multi-dimensional array of 4 * 4 items in [-inf, inf]
-
use_spherical_stereo
(camera)¶ use_spherical_stereo
Returns: Spherical Stereo Return type: boolean
-
update_stats
(stats, info)¶ Update and signal to redraw render status text
Parameters: - stats (string, (never None)) – Stats
- info (string, (never None)) – Info
-
frame_set
(frame, subframe)¶ Evaluate scene at a different frame (for motion blur)
Parameters: - frame (int in [-inf, inf]) – Frame
- subframe (float in [0, 1]) – Subframe
-
update_progress
(progress)¶ Update progress percentage of render
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 usage statistics
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 info, warning or error messages
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
-
error_set
(message)¶ Set error message displaying after the render is finished
Parameters: message (string, (never None)) – Report Message
-
bind_display_space_shader
(scene)¶ Bind GLSL fragment shader that converts linear colors to display space colors using scene color management settings
-
unbind_display_space_shader
()¶ Unbind GLSL display space shader, must always be called after binding the shader
-
support_display_space_shader
(scene)¶ Test if GLSL display space shader is supported for the combination of graphics card and scene settings
Returns: Supported Return type: boolean
-
get_preview_pixel_size
(scene)¶ Get the pixel size that should be used for preview rendering
Returns: Pixel Size Return type: int in [1, 8]
-
register_pass
(scene=None, srl=None, name="", channels=1, chanid="", type='VALUE')¶ Register a render pass that will be part of the render with the current settings
Parameters: - name (string, (optional, never None)) – Name
- channels (int in [1, 8], (optional)) – Channels
- chanid (string, (optional, never None)) – Channel IDs
- type (enum in ['VALUE', 'VECTOR', 'COLOR'], (optional)) – Type
-
classmethod
bl_rna_get_subclass
(id, default=None)¶ Parameters: id (string) – The RNA type identifier. Returns: The RNA type or default when not found. Return type: bpy.types.Struct
subclass
-
classmethod
bl_rna_get_subclass_py
(id, default=None)¶ Parameters: id (string) – The RNA type identifier. Returns: The class or default when not found. Return type: type
-
Inherited Properties
Inherited Functions