From e760972221e68d3c81f2ee3687cc71836dde8ae9 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Dec 2019 19:57:28 +0100 Subject: Cycles: support for custom shader AOVs Custom render passes are added in the Shader AOVs panel in the view layer settings, with a name and data type. In shader nodes, an AOV Output node is then used to output either a value or color to the pass. Arbitrary names can be used for these passes, as long as they don't conflict with built-in passes that are enabled. The AOV Output node can be used in both material and world shader nodes. Implemented by Lukas, with tweaks by Brecht. Differential Revision: https://developer.blender.org/D4837 --- intern/cycles/blender/blender_sync.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f04455ff75e..bb52c740bfb 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -531,7 +531,7 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa if (pass_type == PASS_MOTION && scene->integrator->motion_blur) continue; if (pass_type != PASS_NONE) - Pass::add(pass_type, passes); + Pass::add(pass_type, passes, b_pass.name().c_str()); } PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles"); @@ -570,32 +570,32 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa #ifdef __KERNEL_DEBUG__ if (get_boolean(crp, "pass_debug_bvh_traversed_nodes")) { b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_TRAVERSED_NODES, passes); + Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes"); } if (get_boolean(crp, "pass_debug_bvh_traversed_instances")) { b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes); + Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances"); } if (get_boolean(crp, "pass_debug_bvh_intersections")) { b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_INTERSECTIONS, passes); + Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections"); } if (get_boolean(crp, "pass_debug_ray_bounces")) { b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_RAY_BOUNCES, passes); + Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces"); } #endif if (get_boolean(crp, "pass_debug_render_time")) { b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_RENDER_TIME, passes); + Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time"); } if (get_boolean(crp, "use_pass_volume_direct")) { b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str()); - Pass::add(PASS_VOLUME_DIRECT, passes); + Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir"); } if (get_boolean(crp, "use_pass_volume_indirect")) { b_engine.add_pass("VolumeInd", 3, "RGB", b_view_layer.name().c_str()); - Pass::add(PASS_VOLUME_INDIRECT, passes); + Pass::add(PASS_VOLUME_INDIRECT, passes, "VolumeInd"); } /* Cryptomatte stores two ID/weight pairs per RGBA layer. @@ -635,6 +635,21 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa CRYPT_ACCURATE); } + RNA_BEGIN (&crp, b_aov, "aovs") { + bool is_color = (get_enum(b_aov, "type") == 1); + string name = get_string(b_aov, "name"); + + if (is_color) { + b_engine.add_pass(name.c_str(), 4, "RGBA", b_view_layer.name().c_str()); + Pass::add(PASS_AOV_COLOR, passes, name.c_str()); + } + else { + b_engine.add_pass(name.c_str(), 1, "X", b_view_layer.name().c_str()); + Pass::add(PASS_AOV_VALUE, passes, name.c_str()); + } + } + RNA_END; + return passes; } -- cgit v1.2.3