2022-02-11 13:53:21 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright 2011-2022 Blender Foundation
|
2021-02-21 21:21:18 +11:00
|
|
|
from __future__ import annotations
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2013-01-15 23:17:45 +00:00
|
|
|
|
2017-03-15 15:36:40 +01:00
|
|
|
def _configure_argument_parser():
|
|
|
|
import argparse
|
2018-07-27 11:34:52 +02:00
|
|
|
# No help because it conflicts with general Python scripts argument parsing
|
|
|
|
parser = argparse.ArgumentParser(description="Cycles Addon argument parser",
|
|
|
|
add_help=False)
|
2018-07-27 15:46:13 +02:00
|
|
|
parser.add_argument("--cycles-print-stats",
|
|
|
|
help="Print rendering statistics to stderr",
|
|
|
|
action='store_true')
|
2020-10-02 00:48:01 +02:00
|
|
|
parser.add_argument("--cycles-device",
|
|
|
|
help="Set the device to use for Cycles, overriding user preferences and the scene setting."
|
2022-09-21 12:04:27 +02:00
|
|
|
"Valid options are 'CPU', 'CUDA', 'OPTIX', 'HIP', 'ONEAPI', or 'METAL'."
|
2020-10-02 00:48:01 +02:00
|
|
|
"Additionally, you can append '+CPU' to any GPU type for hybrid rendering.",
|
|
|
|
default=None)
|
2017-03-15 15:36:40 +01:00
|
|
|
return parser
|
|
|
|
|
|
|
|
|
2016-03-30 15:55:12 +02:00
|
|
|
def _parse_command_line():
|
|
|
|
import sys
|
|
|
|
|
|
|
|
argv = sys.argv
|
|
|
|
if "--" not in argv:
|
|
|
|
return
|
|
|
|
|
2017-03-15 15:36:40 +01:00
|
|
|
parser = _configure_argument_parser()
|
2018-11-26 09:26:38 +11:00
|
|
|
args, _ = parser.parse_known_args(argv[argv.index("--") + 1:])
|
2016-03-30 15:55:12 +02:00
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
if args.cycles_print_stats:
|
|
|
|
import _cycles
|
|
|
|
_cycles.enable_print_stats()
|
2016-03-30 15:55:12 +02:00
|
|
|
|
2020-10-02 00:48:01 +02:00
|
|
|
if args.cycles_device:
|
|
|
|
import _cycles
|
|
|
|
_cycles.set_device_override(args.cycles_device)
|
|
|
|
|
2016-03-30 15:55:12 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def init():
|
2012-12-13 08:45:55 +00:00
|
|
|
import bpy
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-08-28 13:55:59 +00:00
|
|
|
import os.path
|
2011-09-09 12:04:39 +00:00
|
|
|
|
|
|
|
path = os.path.dirname(__file__)
|
PyAPI: use keyword only arguments
Use keyword only arguments for the following functions.
- addon_utils.module_bl_info 2nd arg `info_basis`.
- addon_utils.modules 1st `module_cache`, 2nd arg `refresh`.
- addon_utils.modules_refresh 1st arg `module_cache`.
- bl_app_template_utils.activate 1nd arg `template_id`.
- bl_app_template_utils.import_from_id 2nd arg `ignore_not_found`.
- bl_app_template_utils.import_from_path 2nd arg `ignore_not_found`.
- bl_keymap_utils.keymap_from_toolbar.generate 2nd & 3rd args `use_fallback_keys` & `use_reset`.
- bl_keymap_utils.platform_helpers.keyconfig_data_oskey_from_ctrl 2nd arg `filter_fn`.
- bl_ui_utils.bug_report_url.url_prefill_from_blender 1st arg `addon_info`.
- bmesh.types.BMFace.copy 1st & 2nd args `verts`, `edges`.
- bmesh.types.BMesh.calc_volume 1st arg `signed`.
- bmesh.types.BMesh.from_mesh 2nd..4th args `face_normals`, `use_shape_key`, `shape_key_index`.
- bmesh.types.BMesh.from_object 3rd & 4th args `cage`, `face_normals`.
- bmesh.types.BMesh.transform 2nd arg `filter`.
- bmesh.types.BMesh.update_edit_mesh 2nd & 3rd args `loop_triangles`, `destructive`.
- bmesh.types.{BMVertSeq,BMEdgeSeq,BMFaceSeq}.sort 1st & 2nd arg `key`, `reverse`.
- bmesh.utils.face_split 4th..6th args `coords`, `use_exist`, `example`.
- bpy.data.libraries.load 2nd..4th args `link`, `relative`, `assets_only`.
- bpy.data.user_map 1st..3rd args `subset`, `key_types, `value_types`.
- bpy.msgbus.subscribe_rna 5th arg `options`.
- bpy.path.abspath 2nd & 3rd args `start` & `library`.
- bpy.path.clean_name 2nd arg `replace`.
- bpy.path.ensure_ext 3rd arg `case_sensitive`.
- bpy.path.module_names 2nd arg `recursive`.
- bpy.path.relpath 2nd arg `start`.
- bpy.types.EditBone.transform 2nd & 3rd arg `scale`, `roll`.
- bpy.types.Operator.as_keywords 1st arg `ignore`.
- bpy.types.Struct.{keyframe_insert,keyframe_delete} 2nd..5th args `index`, `frame`, `group`, `options`.
- bpy.types.WindowManager.popup_menu 2nd & 3rd arg `title`, `icon`.
- bpy.types.WindowManager.popup_menu_pie 3rd & 4th arg `title`, `icon`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.blend_paths 1st..3rd args `absolute`, `packed`, `local`.
- bpy.utils.execfile 2nd arg `mod`.
- bpy.utils.keyconfig_set 2nd arg `report`.
- bpy.utils.load_scripts 1st & 2nd `reload_scripts` & `refresh_scripts`.
- bpy.utils.preset_find 3rd & 4th args `display_name`, `ext`.
- bpy.utils.resource_path 2nd & 3rd arg `major`, `minor`.
- bpy.utils.script_paths 1st..4th args `subdir`, `user_pref`, `check_all`, `use_user`.
- bpy.utils.smpte_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.smpte_from_seconds 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.system_resource 2nd arg `subdir`.
- bpy.utils.time_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.time_to_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.units.to_string 4th..6th `precision`, `split_unit`, `compatible_unit`.
- bpy.utils.units.to_value 4th arg `str_ref_unit`.
- bpy.utils.user_resource 2nd & 3rd args `subdir`, `create`
- bpy_extras.view3d_utils.location_3d_to_region_2d 4th arg `default`.
- bpy_extras.view3d_utils.region_2d_to_origin_3d 4th arg `clamp`.
- gpu.offscreen.unbind 1st arg `restore`.
- gpu_extras.batch.batch_for_shader 4th arg `indices`.
- gpu_extras.batch.presets.draw_circle_2d 4th arg `segments`.
- gpu_extras.presets.draw_circle_2d 4th arg `segments`.
- imbuf.types.ImBuf.resize 2nd arg `resize`.
- imbuf.write 2nd arg `filepath`.
- mathutils.kdtree.KDTree.find 2nd arg `filter`.
- nodeitems_utils.NodeCategory 3rd & 4th arg `descriptions`, `items`.
- nodeitems_utils.NodeItem 2nd..4th args `label`, `settings`, `poll`.
- nodeitems_utils.NodeItemCustom 1st & 2nd arg `poll`, `draw`.
- rna_prop_ui.draw 5th arg `use_edit`.
- rna_prop_ui.rna_idprop_ui_get 2nd arg `create`.
- rna_prop_ui.rna_idprop_ui_prop_clear 3rd arg `remove`.
- rna_prop_ui.rna_idprop_ui_prop_get 3rd arg `create`.
- rna_xml.xml2rna 2nd arg `root_rna`.
- rna_xml.xml_file_write 4th arg `skip_typemap`.
2021-06-08 18:03:14 +10:00
|
|
|
user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', path='')))
|
2011-09-09 12:04:39 +00:00
|
|
|
|
2022-01-10 16:05:17 +01:00
|
|
|
_cycles.init(path, user_path, bpy.app.background)
|
2016-03-30 15:55:12 +02:00
|
|
|
_parse_command_line()
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2016-08-01 11:54:02 +10:00
|
|
|
|
2016-02-07 03:40:41 +05:00
|
|
|
def exit():
|
|
|
|
import _cycles
|
|
|
|
_cycles.exit()
|
|
|
|
|
2016-08-01 11:54:02 +10:00
|
|
|
|
2018-05-23 12:13:21 +02:00
|
|
|
def create(engine, data, region=None, v3d=None, rv3d=None, preview_osl=False):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2018-05-23 12:13:21 +02:00
|
|
|
import bpy
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
data = data.as_pointer()
|
2018-12-21 12:47:44 +11:00
|
|
|
prefs = bpy.context.preferences.as_pointer()
|
2019-09-12 10:25:39 +02:00
|
|
|
screen = 0
|
2011-08-28 13:55:59 +00:00
|
|
|
if region:
|
2019-09-11 08:22:53 +02:00
|
|
|
screen = region.id_data.as_pointer()
|
2011-08-28 13:55:59 +00:00
|
|
|
region = region.as_pointer()
|
|
|
|
if v3d:
|
2019-09-11 08:22:53 +02:00
|
|
|
screen = screen or v3d.id_data.as_pointer()
|
2011-08-28 13:55:59 +00:00
|
|
|
v3d = v3d.as_pointer()
|
|
|
|
if rv3d:
|
2019-09-11 08:22:53 +02:00
|
|
|
screen = screen or rv3d.id_data.as_pointer()
|
2011-08-28 13:55:59 +00:00
|
|
|
rv3d = rv3d.as_pointer()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2019-09-11 08:22:53 +02:00
|
|
|
engine.session = _cycles.create(engine.as_pointer(), prefs, data, screen, region, v3d, rv3d, preview_osl)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def free(engine):
|
2011-11-15 02:58:01 +00:00
|
|
|
if hasattr(engine, "session"):
|
2011-08-28 13:55:59 +00:00
|
|
|
if engine.session:
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
_cycles.free(engine.session)
|
2011-08-28 13:55:59 +00:00
|
|
|
del engine.session
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2017-04-25 16:18:24 +02:00
|
|
|
def render(engine, depsgraph):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2011-11-27 03:49:09 +00:00
|
|
|
if hasattr(engine, "session"):
|
2018-02-26 16:46:48 +01:00
|
|
|
_cycles.render(engine.session, depsgraph.as_pointer())
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
def render_frame_finish(engine):
|
|
|
|
if not engine.session:
|
|
|
|
return
|
|
|
|
|
|
|
|
import _cycles
|
|
|
|
_cycles.render_frame_finish(engine.session)
|
|
|
|
|
2022-04-20 16:07:03 +10:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
def draw(engine, depsgraph, space_image):
|
|
|
|
if not engine.session:
|
|
|
|
return
|
|
|
|
|
|
|
|
depsgraph_ptr = depsgraph.as_pointer()
|
|
|
|
space_image_ptr = space_image.as_pointer()
|
|
|
|
screen_ptr = space_image.id_data.as_pointer()
|
|
|
|
|
|
|
|
import _cycles
|
|
|
|
_cycles.draw(engine.session, depsgraph_ptr, screen_ptr, space_image_ptr)
|
|
|
|
|
|
|
|
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
def bake(engine, depsgraph, obj, pass_type, pass_filter, width, height):
|
2014-01-02 19:05:07 -02:00
|
|
|
import _cycles
|
|
|
|
session = getattr(engine, "session", None)
|
|
|
|
if session is not None:
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
_cycles.bake(engine.session, depsgraph.as_pointer(), obj.as_pointer(), pass_type, pass_filter, width, height)
|
2014-01-02 19:05:07 -02:00
|
|
|
|
2014-07-22 12:03:15 +10:00
|
|
|
|
2018-05-23 12:13:21 +02:00
|
|
|
def reset(engine, data, depsgraph):
|
2012-11-09 08:46:53 +00:00
|
|
|
import _cycles
|
2018-05-23 12:13:21 +02:00
|
|
|
import bpy
|
|
|
|
|
2020-06-11 20:32:39 +02:00
|
|
|
prefs = bpy.context.preferences
|
|
|
|
if prefs.experimental.use_cycles_debug and prefs.view.show_developer_ui:
|
2018-07-25 19:15:20 +02:00
|
|
|
_cycles.debug_flags_update(depsgraph.scene.as_pointer())
|
2018-05-23 12:13:21 +02:00
|
|
|
else:
|
|
|
|
_cycles.debug_flags_reset()
|
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
data = data.as_pointer()
|
2018-05-23 12:13:21 +02:00
|
|
|
depsgraph = depsgraph.as_pointer()
|
|
|
|
_cycles.reset(engine.session, data, depsgraph)
|
2012-11-09 08:46:53 +00:00
|
|
|
|
|
|
|
|
2018-05-23 12:13:21 +02:00
|
|
|
def sync(engine, depsgraph, data):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2018-02-26 16:46:48 +01:00
|
|
|
_cycles.sync(engine.session, depsgraph.as_pointer())
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
def view_draw(engine, depsgraph, region, v3d, rv3d):
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
2017-04-25 16:18:24 +02:00
|
|
|
depsgraph = depsgraph.as_pointer()
|
2011-08-28 13:55:59 +00:00
|
|
|
v3d = v3d.as_pointer()
|
|
|
|
rv3d = rv3d.as_pointer()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
# draw render image
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
_cycles.view_draw(engine.session, depsgraph, v3d, rv3d)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def available_devices():
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
return _cycles.available_devices()
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def with_osl():
|
2011-12-24 02:47:13 +00:00
|
|
|
import _cycles
|
|
|
|
return _cycles.with_osl
|
2014-02-13 08:51:33 +11:00
|
|
|
|
2022-11-10 11:17:16 +11:00
|
|
|
|
2022-11-09 14:25:32 +01:00
|
|
|
def osl_version():
|
|
|
|
import _cycles
|
|
|
|
return _cycles.osl_version
|
|
|
|
|
2014-02-13 08:51:33 +11:00
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
def with_path_guiding():
|
|
|
|
import _cycles
|
|
|
|
return _cycles.with_path_guiding
|
|
|
|
|
|
|
|
|
2015-01-06 14:13:21 +05:00
|
|
|
def system_info():
|
|
|
|
import _cycles
|
|
|
|
return _cycles.system_info()
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
|
2020-10-02 10:10:01 +10:00
|
|
|
|
2020-07-07 14:45:31 +02:00
|
|
|
def list_render_passes(scene, srl):
|
2023-04-13 10:27:07 +02:00
|
|
|
import _cycles
|
|
|
|
|
2021-07-29 16:39:19 +02:00
|
|
|
crl = srl.cycles
|
|
|
|
|
|
|
|
# Combined pass.
|
2019-12-04 19:57:28 +01:00
|
|
|
yield ("Combined", "RGBA", 'COLOR')
|
|
|
|
|
2022-04-20 16:07:03 +10:00
|
|
|
# Keep alignment for readability.
|
|
|
|
# autopep8: off
|
|
|
|
|
2021-07-29 16:39:19 +02:00
|
|
|
# Data passes.
|
2019-12-04 19:57:28 +01:00
|
|
|
if srl.use_pass_z: yield ("Depth", "Z", 'VALUE')
|
|
|
|
if srl.use_pass_mist: yield ("Mist", "Z", 'VALUE')
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if srl.use_pass_position: yield ("Position", "XYZ", 'VECTOR')
|
2019-12-04 19:57:28 +01:00
|
|
|
if srl.use_pass_normal: yield ("Normal", "XYZ", 'VECTOR')
|
|
|
|
if srl.use_pass_vector: yield ("Vector", "XYZW", 'VECTOR')
|
|
|
|
if srl.use_pass_uv: yield ("UV", "UVA", 'VECTOR')
|
|
|
|
if srl.use_pass_object_index: yield ("IndexOB", "X", 'VALUE')
|
|
|
|
if srl.use_pass_material_index: yield ("IndexMA", "X", 'VALUE')
|
2021-07-29 16:39:19 +02:00
|
|
|
|
|
|
|
# Light passes.
|
2019-12-04 19:57:28 +01:00
|
|
|
if srl.use_pass_diffuse_direct: yield ("DiffDir", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_diffuse_indirect: yield ("DiffInd", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_diffuse_color: yield ("DiffCol", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_glossy_direct: yield ("GlossDir", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_glossy_indirect: yield ("GlossInd", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_glossy_color: yield ("GlossCol", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_transmission_direct: yield ("TransDir", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_transmission_indirect: yield ("TransInd", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_transmission_color: yield ("TransCol", "RGB", 'COLOR')
|
2021-07-29 16:39:19 +02:00
|
|
|
if crl.use_pass_volume_direct: yield ("VolumeDir", "RGB", 'COLOR')
|
|
|
|
if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR')
|
2019-12-04 19:57:28 +01:00
|
|
|
if srl.use_pass_emit: yield ("Emit", "RGB", 'COLOR')
|
|
|
|
if srl.use_pass_environment: yield ("Env", "RGB", 'COLOR')
|
2021-07-29 16:39:19 +02:00
|
|
|
if srl.use_pass_ambient_occlusion: yield ("AO", "RGB", 'COLOR')
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if crl.use_pass_shadow_catcher: yield ("Shadow Catcher", "RGB", 'COLOR')
|
2022-04-20 16:07:03 +10:00
|
|
|
# autopep8: on
|
2019-12-04 19:57:28 +01:00
|
|
|
|
2021-07-29 16:39:19 +02:00
|
|
|
# Debug passes.
|
2022-04-20 16:07:03 +10:00
|
|
|
if crl.pass_debug_sample_count:
|
|
|
|
yield ("Debug Sample Count", "X", 'VALUE')
|
2019-12-04 19:57:28 +01:00
|
|
|
|
|
|
|
# Cryptomatte passes.
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
# NOTE: Name channels are lowercase RGBA so that compression rules check in OpenEXR DWA code
|
|
|
|
# uses lossless compression. Reportedly this naming is the only one which works good from the
|
|
|
|
# interoperability point of view. Using XYZW naming is not portable.
|
|
|
|
crypto_depth = (min(16, srl.pass_cryptomatte_depth) + 1) // 2
|
2020-12-07 07:50:14 +01:00
|
|
|
if srl.use_pass_cryptomatte_object:
|
2020-04-03 01:47:23 +02:00
|
|
|
for i in range(0, crypto_depth):
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
yield ("CryptoObject" + '{:02d}'.format(i), "rgba", 'COLOR')
|
2020-12-07 07:50:14 +01:00
|
|
|
if srl.use_pass_cryptomatte_material:
|
2020-04-03 01:47:23 +02:00
|
|
|
for i in range(0, crypto_depth):
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
yield ("CryptoMaterial" + '{:02d}'.format(i), "rgba", 'COLOR')
|
2020-12-07 07:50:14 +01:00
|
|
|
if srl.use_pass_cryptomatte_asset:
|
2020-04-03 01:47:23 +02:00
|
|
|
for i in range(0, crypto_depth):
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
yield ("CryptoAsset" + '{:02d}'.format(i), "rgba", 'COLOR')
|
2018-10-28 05:37:41 -04:00
|
|
|
|
2019-12-04 19:57:28 +01:00
|
|
|
# Denoising passes.
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if scene.cycles.use_denoising and crl.use_denoising:
|
2019-12-04 19:57:28 +01:00
|
|
|
yield ("Noisy Image", "RGBA", 'COLOR')
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if crl.use_pass_shadow_catcher:
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
yield ("Noisy Shadow Catcher", "RGB", 'COLOR')
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if crl.denoising_store_passes:
|
2022-04-20 16:07:03 +10:00
|
|
|
yield ("Denoising Normal", "XYZ", 'VECTOR')
|
|
|
|
yield ("Denoising Albedo", "RGB", 'COLOR')
|
|
|
|
yield ("Denoising Depth", "Z", 'VALUE')
|
2019-12-04 19:57:28 +01:00
|
|
|
|
|
|
|
# Custom AOV passes.
|
2021-02-12 11:29:50 +01:00
|
|
|
for aov in srl.aovs:
|
Fix T93382: Blender still generates subsurface render passes
In T93382, the problem was that the Blender-side rendering code was
still generating the subsurface passes because the old render pass
flags were set, even though Cycles doesn't generate them anymore.
After a closer look, it turns out that the entire hardcoded pass
creation code can be removed. We already have an Engine API function
to query the list of render passes from the engine, so we might as
well just call that and create the returned passes.
Turns out that Eevee already did this anyways. On the Cycles side, it
allows to deduplicate a lot of `BlenderSync::sync_render_passes`.
Before, passes were defined in engine.py and in sync.cpp. Now, all
passes that engine.py returns are created automatically, so sync.cpp
only needs to handle a few special cases.
I'm not really concerned about affecting external renderer addons,
since they already needed to handle the old "builtin passes" in
their Engine API implementation anyways to make them show up in the
compositor. So, unless they missed that for like 10 releases, they
should not notice any difference.
Differential Revision: https://developer.blender.org/D16295
2022-10-19 04:02:39 +02:00
|
|
|
if not aov.is_valid:
|
|
|
|
continue
|
2019-12-04 19:57:28 +01:00
|
|
|
if aov.type == 'VALUE':
|
|
|
|
yield (aov.name, "X", 'VALUE')
|
|
|
|
else:
|
2022-04-08 01:14:01 +02:00
|
|
|
yield (aov.name, "RGBA", 'COLOR')
|
2019-12-04 19:57:28 +01:00
|
|
|
|
2022-04-02 00:11:11 +02:00
|
|
|
# Light groups.
|
|
|
|
for lightgroup in srl.lightgroups:
|
|
|
|
yield ("Combined_%s" % lightgroup.name, "RGB", 'COLOR')
|
|
|
|
|
2023-04-13 10:27:07 +02:00
|
|
|
# Path guiding debug passes.
|
|
|
|
if _cycles.with_debug:
|
|
|
|
yield ("Guiding Color", "RGB", 'COLOR')
|
|
|
|
yield ("Guiding Probability", "X", 'VALUE')
|
|
|
|
yield ("Guiding Average Roughness", "X", 'VALUE')
|
|
|
|
|
2020-10-02 10:10:01 +10:00
|
|
|
|
2019-12-04 19:57:28 +01:00
|
|
|
def register_passes(engine, scene, view_layer):
|
2020-07-07 14:45:31 +02:00
|
|
|
for name, channelids, channeltype in list_render_passes(scene, view_layer):
|
2021-02-12 11:29:50 +01:00
|
|
|
engine.register_pass(scene, view_layer, name, len(channelids), channelids, channeltype)
|