diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2022-04-02 01:11:11 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2022-04-02 07:14:27 +0300 |
commit | ad35453cd19b3db779b0b3a90feac2e93c7a73cf (patch) | |
tree | 3ad7893815bda3e34e18302422ad1f978e828603 /source/blender/blenkernel/intern/world.c | |
parent | 5387d33e5f954c4cecdb7ffd3d1042d8632d6c15 (diff) |
Cycles: Add support for light groups
Light groups are a type of pass that only contains lighting from a subset of light sources.
They are created in the View layer, and light sources (lamps, objects with emissive materials
and/or the environment) can be assigned to a group.
Currently, each light group ends up generating its own version of the Combined pass.
In the future, additional types of passes (e.g. shadowcatcher) might be getting their own
per-lightgroup versions.
The lightgroup creation and assignment is not Cycles-specific, so Eevee or external render
engines could make use of it in the future.
Note that Lightgroups are identified by their name - therefore, the name of the Lightgroup
in the View Layer and the name that's set in an object's settings must match for it to be
included.
Currently, changing a Lightgroup's name does not update objects - this is planned for the
future, along with other features such as denoising for light groups and viewing them in
preview renders.
Original patch by Alex Fuller (@mistaed), with some polishing by Lukas Stockner (@lukasstockner97).
Differential Revision: https://developer.blender.org/D12871
Diffstat (limited to 'source/blender/blenkernel/intern/world.c')
-rw-r--r-- | source/blender/blenkernel/intern/world.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index ac8b18f3395..cc3ee06f539 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -59,6 +59,8 @@ static void world_free_data(ID *id) BKE_icon_id_delete((struct ID *)wrld); BKE_previewimg_free(&wrld->preview); + + MEM_SAFE_FREE(wrld->lightgroup); } static void world_init_data(ID *id) @@ -107,6 +109,10 @@ static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int else { wrld_dst->preview = NULL; } + + if (wrld_src->lightgroup) { + wrld_dst->lightgroup = (LightgroupMembership *)MEM_dupallocN(wrld_src->lightgroup); + } } static void world_foreach_id(ID *id, LibraryForeachIDData *data) @@ -142,6 +148,10 @@ static void world_blend_write(BlendWriter *writer, ID *id, const void *id_addres } BKE_previewimg_blend_write(writer, wrld->preview); + + if (wrld->lightgroup) { + BLO_write_struct(writer, LightgroupMembership, wrld->lightgroup); + } } static void world_blend_read_data(BlendDataReader *reader, ID *id) @@ -153,6 +163,8 @@ static void world_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_data_address(reader, &wrld->preview); BKE_previewimg_blend_read(reader, wrld->preview); BLI_listbase_clear(&wrld->gpumaterial); + + BLO_read_data_address(reader, &wrld->lightgroup); } static void world_blend_read_lib(BlendLibReader *reader, ID *id) |