Cycles: Use Blender Cryptomatte Settings.
Blender has now the place to store the Cryptomatte settings. This patch migrates Cycles to use the new settings. Reviewed By: Brecht van Lommel Differential Revision: https://developer.blender.org/D9746
This commit is contained in:
parent
3d0b65f89b
commit
5baae026a8
Notes:
blender-bot
2023-02-13 20:35:11 +01:00
Referenced by commit 7d2745f8b3
, Fix Cryptomatte panel not visible in EEVEE
Referenced by issue #82575, Cryptomatte: Merge the cycles and eevee settings
|
@ -270,14 +270,14 @@ def list_render_passes(scene, srl):
|
|||
if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR')
|
||||
|
||||
# Cryptomatte passes.
|
||||
crypto_depth = (crl.pass_crypto_depth + 1) // 2
|
||||
if crl.use_pass_crypto_object:
|
||||
crypto_depth = (srl.pass_cryptomatte_depth + 1) // 2
|
||||
if srl.use_pass_cryptomatte_object:
|
||||
for i in range(0, crypto_depth):
|
||||
yield ("CryptoObject" + '{:02d}'.format(i), "RGBA", 'COLOR')
|
||||
if crl.use_pass_crypto_material:
|
||||
if srl.use_pass_cryptomatte_material:
|
||||
for i in range(0, crypto_depth):
|
||||
yield ("CryptoMaterial" + '{:02d}'.format(i), "RGBA", 'COLOR')
|
||||
if srl.cycles.use_pass_crypto_asset:
|
||||
if srl.use_pass_cryptomatte_asset:
|
||||
for i in range(0, crypto_depth):
|
||||
yield ("CryptoAsset" + '{:02d}'.format(i), "RGBA", 'COLOR')
|
||||
|
||||
|
|
|
@ -1470,37 +1470,6 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
|
|||
default='RGB_ALBEDO_NORMAL',
|
||||
)
|
||||
|
||||
use_pass_crypto_object: BoolProperty(
|
||||
name="Cryptomatte Object",
|
||||
description="Render cryptomatte object pass, for isolating objects in compositing",
|
||||
default=False,
|
||||
update=update_render_passes,
|
||||
)
|
||||
use_pass_crypto_material: BoolProperty(
|
||||
name="Cryptomatte Material",
|
||||
description="Render cryptomatte material pass, for isolating materials in compositing",
|
||||
default=False,
|
||||
update=update_render_passes,
|
||||
)
|
||||
use_pass_crypto_asset: BoolProperty(
|
||||
name="Cryptomatte Asset",
|
||||
description="Render cryptomatte asset pass, for isolating groups of objects with the same parent",
|
||||
default=False,
|
||||
update=update_render_passes,
|
||||
)
|
||||
pass_crypto_depth: IntProperty(
|
||||
name="Cryptomatte Levels",
|
||||
description="Sets how many unique objects can be distinguished per pixel",
|
||||
default=6, min=2, max=16, step=2,
|
||||
update=update_render_passes,
|
||||
)
|
||||
pass_crypto_accurate: BoolProperty(
|
||||
name="Cryptomatte Accurate",
|
||||
description="Generate a more accurate Cryptomatte pass. CPU only, may render slower and use more memory",
|
||||
default=True,
|
||||
update=update_render_passes,
|
||||
)
|
||||
|
||||
aovs: CollectionProperty(
|
||||
type=CyclesAOVPass,
|
||||
description="Custom render passes that can be output by shader nodes",
|
||||
|
|
|
@ -23,6 +23,7 @@ from bl_ui.utils import PresetPanel
|
|||
from bpy.types import Panel
|
||||
|
||||
from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel
|
||||
from bl_ui.properties_view_layer import VIEWLAYER_PT_layer_passes_cryptomatte
|
||||
|
||||
|
||||
class CYCLES_PT_sampling_presets(PresetPanel, Panel):
|
||||
|
@ -885,31 +886,11 @@ class CYCLES_RENDER_PT_passes_light(CyclesButtonsPanel, Panel):
|
|||
col.prop(view_layer, "use_pass_ambient_occlusion", text="Ambient Occlusion")
|
||||
|
||||
|
||||
class CYCLES_RENDER_PT_passes_crypto(CyclesButtonsPanel, Panel):
|
||||
class CYCLES_RENDER_PT_passes_crypto(CyclesButtonsPanel, VIEWLAYER_PT_layer_passes_cryptomatte):
|
||||
bl_label = "Cryptomatte"
|
||||
bl_context = "view_layer"
|
||||
bl_parent_id = "CYCLES_RENDER_PT_passes"
|
||||
|
||||
def draw(self, context):
|
||||
import _cycles
|
||||
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False
|
||||
|
||||
cycles_view_layer = context.view_layer.cycles
|
||||
|
||||
col = layout.column(heading="Include", align=True)
|
||||
col.prop(cycles_view_layer, "use_pass_crypto_object", text="Object")
|
||||
col.prop(cycles_view_layer, "use_pass_crypto_material", text="Material")
|
||||
col.prop(cycles_view_layer, "use_pass_crypto_asset", text="Asset")
|
||||
|
||||
layout.prop(cycles_view_layer, "pass_crypto_depth", text="Levels")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.active = use_cpu(context)
|
||||
row.prop(cycles_view_layer, "pass_crypto_accurate", text="Accurate Mode")
|
||||
|
||||
|
||||
class CYCLES_RENDER_PT_passes_debug(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Debug"
|
||||
|
|
|
@ -108,7 +108,7 @@ def do_versions(self):
|
|||
library_versions.setdefault(library.version, []).append(library)
|
||||
|
||||
# Do versioning per library, since they might have different versions.
|
||||
max_need_versioning = (2, 80, 41)
|
||||
max_need_versioning = (2, 90, 0)
|
||||
for version, libraries in library_versions.items():
|
||||
if version > max_need_versioning:
|
||||
continue
|
||||
|
@ -194,6 +194,16 @@ def do_versions(self):
|
|||
if not cscene.is_property_set("sample_clamp_indirect"):
|
||||
cscene.sample_clamp_indirect = 0.0
|
||||
|
||||
if version <= (2, 91, 0):
|
||||
if scene.render.engine == 'CYCLES':
|
||||
for view_layer in scene.view_layers:
|
||||
cview_layer = view_layer.cycles
|
||||
view_layer.use_pass_cryptomatte_object = cview_layer.get("use_pass_crypto_object")
|
||||
view_layer.use_pass_cryptomatte_material = cview_layer.get("use_pass_crypto_material")
|
||||
view_layer.use_pass_cryptomatte_asset = cview_layer.get("use_pass_crypto_asset")
|
||||
view_layer.pass_cryptomatte_depth = cview_layer.get("pass_crypto_depth")
|
||||
view_layer.use_pass_cryptomatte_accurate = cview_layer.get("pass_crypto_accurate")
|
||||
|
||||
# Lamps
|
||||
for light in bpy.data.lights:
|
||||
if light.library not in libraries:
|
||||
|
|
|
@ -667,10 +667,10 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
|
|||
|
||||
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
|
||||
* User facing parameter is the number of pairs. */
|
||||
int crypto_depth = divide_up(min(16, get_int(crl, "pass_crypto_depth")), 2);
|
||||
int crypto_depth = divide_up(min(16, b_view_layer.pass_cryptomatte_depth()), 2);
|
||||
scene->film->set_cryptomatte_depth(crypto_depth);
|
||||
CryptomatteType cryptomatte_passes = CRYPT_NONE;
|
||||
if (get_boolean(crl, "use_pass_crypto_object")) {
|
||||
if (b_view_layer.use_pass_cryptomatte_object()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Object%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
||||
|
@ -678,7 +678,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
|
|||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
|
||||
}
|
||||
if (get_boolean(crl, "use_pass_crypto_material")) {
|
||||
if (b_view_layer.use_pass_cryptomatte_material()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Material%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
||||
|
@ -686,7 +686,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
|
|||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
|
||||
}
|
||||
if (get_boolean(crl, "use_pass_crypto_asset")) {
|
||||
if (b_view_layer.use_pass_cryptomatte_asset()) {
|
||||
for (int i = 0; i < crypto_depth; i++) {
|
||||
string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
|
||||
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
||||
|
@ -694,7 +694,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
|
|||
}
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
|
||||
}
|
||||
if (get_boolean(crl, "pass_crypto_accurate") && cryptomatte_passes != CRYPT_NONE) {
|
||||
if (b_view_layer.use_pass_cryptomatte_accurate() && cryptomatte_passes != CRYPT_NONE) {
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ACCURATE);
|
||||
}
|
||||
scene->film->set_cryptomatte_passes(cryptomatte_passes);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 672cfe9c85e2ac71b97b5331d9034d23c9723d71
|
||||
Subproject commit 7faa6b379fd818b8af8cf8279ff9f43cbdbb169e
|
Loading…
Reference in New Issue