diff options
author | Lukas Stockner <lukasstockner97> | 2019-12-04 21:57:28 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-12-10 22:44:46 +0300 |
commit | e760972221e68d3c81f2ee3687cc71836dde8ae9 (patch) | |
tree | b1a2efbb17c05a429e4509d336a1eb14c73cfb8c /intern/cycles/render/film.cpp | |
parent | 35b5888b157d05d378df3acc899d28856a9eb9a4 (diff) |
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
Diffstat (limited to 'intern/cycles/render/film.cpp')
-rw-r--r-- | intern/cycles/render/film.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 7f5bec2a66e..379b0e6c214 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -163,6 +163,12 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name) case PASS_CRYPTOMATTE: pass.components = 4; break; + case PASS_AOV_COLOR: + pass.components = 4; + break; + case PASS_AOV_VALUE: + pass.components = 1; + break; default: assert(false); break; @@ -327,7 +333,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) kfilm->pass_stride = 0; kfilm->use_light_pass = use_light_visibility || use_sample_clamp; - bool have_cryptomatte = false; + bool have_cryptomatte = false, have_aov_color = false, have_aov_value = false; for (size_t i = 0; i < passes.size(); i++) { Pass &pass = passes[i]; @@ -464,6 +470,18 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) kfilm->pass_stride; have_cryptomatte = true; break; + case PASS_AOV_COLOR: + if (!have_aov_color) { + kfilm->pass_aov_color = kfilm->pass_stride; + have_aov_color = true; + } + break; + case PASS_AOV_VALUE: + if (!have_aov_value) { + kfilm->pass_aov_value = kfilm->pass_stride; + have_aov_value = true; + } + break; default: assert(false); break; @@ -569,4 +587,27 @@ void Film::tag_update(Scene * /*scene*/) need_update = true; } +int Film::get_aov_offset(string name, bool &is_color) +{ + int num_color = 0, num_value = 0; + foreach (const Pass &pass, passes) { + if (pass.type == PASS_AOV_COLOR) { + num_color++; + } + else if (pass.type == PASS_AOV_VALUE) { + num_value++; + } + else { + continue; + } + + if (pass.name == name) { + is_color = (pass.type == PASS_AOV_COLOR); + return (is_color ? num_color : num_value) - 1; + } + } + + return -1; +} + CCL_NAMESPACE_END |