(1) Depsgraph and collection enable/visibility:
ClosedPublic

Authored by Dalai Felinto (dfelinto) on Sep 20 2017, 6:47 PM.

Details

Summary

Iterate over invisible objects too, so they can cast shadows, ...
Also, now you can use a collection to set an object to invisible, not
only to visible.

For example:
Scene > Master collection > bedroom > furniture
Scene > View Layer > bedroom (visible)

> furniture  (invisible)

The View Layer has two linked collections, bedroom and furniture.
This setup will make the furniture collection invisible.

Pending Task:

  • Draw invisible objects in the lightprobes
  • Make that work for Cycles too (tackled Eevee and draw manager at first)

(2) Cycles to use collection visibility

Note: this could be named "visible" instead, and I think it should in the end.
But for now if we do it it conflicts with visible_get.

In the near future we could/should move visible_get and select_get to the scene
layers.

Patch by Brecht Van Lommel.


@Sergey Sharybin (sergey), let me know your thoughts on the Depsgraph part?

Diff Detail

Repository
rB Blender

Guess it's more matter of question whether object visibility affects on "visibility for camera" or "visibility for everything". This patch switched from latter to former one, which could work but is a bit weird. Means, making objects invisible wouldn't really speed up your viewport -- shadow buffers will still be recalculated. But guess it was a design discussion i've missed.

As for the code:

  • Don't be lazy, replace meaningless while with if statement. Sure, it's more lines changed, but it is important to keep code really clear.
  • There are lots of same bitflag checks in draw manager. Making it an utility function will ensure code never gets diverged from what it should be. Same function could be used by draw manager and object.hidden RNA.
source/blender/depsgraph/intern/depsgraph_query.cc
213–214

You don't need while here, it should just be if (base != NULL).

  • Rename: hidden > is_visible
  • From review: loop cleanup
  • From review: BKE_object_is_visible() util

Guess it's more matter of question whether object visibility affects on "visibility for camera" or "visibility for everything". This patch switched from latter to former one, which could work but is a bit weird. Means, making objects invisible wouldn't really speed up your viewport -- shadow buffers will still be recalculated.

Correct. To speed up your viewport you will need to disable the collections, not make them invisible.

This was extrapolated from the enabling/disabling collections design.

If we want a lamp and light probes (and empties, ...) to be hidden yet still effect the scene, why not do the same for meshes? Otherwise to disable a collection and make it invisible would be the same.
It also builds on the idea that different (view) layers are cut from the same scene, but seeing as different parts of it. It's how we did compositing with multi-layers for BI and Cycles in 2.7 too.

If you don't agree with it, I will remove the mesh related part of the code, and we discuss this separately.

This revision was automatically updated to reflect the committed changes.

For the records, I committed this without the changes @Sergey Sharybin (sergey) was raising concerns about. I'll open a new patch to discuss this.