Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/scene/film.cpp')
-rw-r--r--intern/cycles/scene/film.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/intern/cycles/scene/film.cpp b/intern/cycles/scene/film.cpp
index e17c839d60b..c3b126544c4 100644
--- a/intern/cycles/scene/film.cpp
+++ b/intern/cycles/scene/film.cpp
@@ -175,6 +175,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_volume_direct = PASS_UNUSED;
kfilm->pass_volume_indirect = PASS_UNUSED;
kfilm->pass_shadow = PASS_UNUSED;
+ kfilm->pass_lightgroup = PASS_UNUSED;
/* Mark passes as unused so that the kernel knows the pass is inaccessible. */
kfilm->pass_denoising_normal = PASS_UNUSED;
@@ -189,6 +190,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
bool have_cryptomatte = false;
bool have_aov_color = false;
bool have_aov_value = false;
+ bool have_lightgroup = false;
for (size_t i = 0; i < scene->passes.size(); i++) {
const Pass *pass = scene->passes[i];
@@ -223,6 +225,15 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
assert(pass->get_type() <= PASS_CATEGORY_BAKE_END);
}
+ if (pass->get_lightgroup() != ustring()) {
+ if (!have_lightgroup) {
+ kfilm->pass_lightgroup = kfilm->pass_stride;
+ have_lightgroup = true;
+ }
+ kfilm->pass_stride += pass->get_info().num_components;
+ continue;
+ }
+
switch (pass->get_type()) {
case PASS_COMBINED:
kfilm->pass_combined = kfilm->pass_stride;
@@ -414,6 +425,26 @@ int Film::get_aov_offset(Scene *scene, string name, bool &is_color)
return -1;
}
+bool Film::update_lightgroups(Scene *scene)
+{
+ map<ustring, int> lightgroups;
+ int i = 0;
+ foreach (const Pass *pass, scene->passes) {
+ ustring lightgroup = pass->get_lightgroup();
+ if (!lightgroup.empty()) {
+ if (!lightgroups.count(lightgroup)) {
+ lightgroups[lightgroup] = i++;
+ }
+ }
+ }
+ if (scene->lightgroups != lightgroups) {
+ scene->lightgroups = lightgroups;
+ return true;
+ }
+
+ return false;
+}
+
void Film::update_passes(Scene *scene, bool add_sample_count_pass)
{
const Background *background = scene->background;
@@ -580,11 +611,19 @@ void Film::remove_auto_passes(Scene *scene)
static bool compare_pass_order(const Pass *a, const Pass *b)
{
+ /* On the highest level, sort by number of components.
+ * Within passes of the same component count, sort so that all non-lightgroup passes come first.
+ * Within that group, sort by type. */
const int num_components_a = a->get_info().num_components;
const int num_components_b = b->get_info().num_components;
if (num_components_a == num_components_b) {
- return (a->get_type() < b->get_type());
+ const int is_lightgroup_a = !a->get_lightgroup().empty();
+ const int is_lightgroup_b = !b->get_lightgroup().empty();
+ if (is_lightgroup_a == is_lightgroup_b) {
+ return (a->get_type() < b->get_type());
+ }
+ return is_lightgroup_b;
}
return num_components_a > num_components_b;