Deleting an unused light group caused the environment light group to render to another light group #117586

Closed
opened 2024-01-28 11:15:44 +01:00 by Mark Stead · 6 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3080/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 546.17

Blender Version
Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: 9be62e85b727
Worked: (newest version of Blender that worked as expected)

Short description of error
When persistent data enabled, deleting an unused light group caused the environment light group to render to another light group

Exact steps for others to reproduce the error
Ok, I've figured out how to reproduce. I needed to have Persistent Data enabled. I've attached a file that demonstrates the problem.

  1. Render the scene once. Observe the different lightgroup render layers. The Combined_Environment layer has the default world illumination.
    image

  2. Delete the Unused Light Group.
    image

  3. Render the scene again.

  4. Observe that the Combined_Environment is now black. Instead that pass is now part of Combined_Green.

117586 Light Group Delete Problem.blend

Anyway, given I cannot reproduce in a standalone file, I'm happy to analyse and debug the problem myself.
Using the Python console, I've tried to look through all the data structures but cannot see anything that looks strange.
Looking at the C++ code (BKE_view_layer_remove_lightgroup()) it only appears to change the active lightgroup, then remove the selected record from the linked list. Maybe some other part of the code is using a pointer to that linked list record - though doesn't seem logical that it would then render to a different lightgroup.
I'll get the latest version of the code compiling and run it in the debugger tomorrow.
However my gut feel is that the blend file is a bit messed-up or inconsistent - it's gone through many different Blender versions.
Is there anything specific I should look at in Python or C++?

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3080/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 546.17 **Blender Version** Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: `9be62e85b727` Worked: (newest version of Blender that worked as expected) **Short description of error** When persistent data enabled, deleting an unused light group caused the environment light group to render to another light group **Exact steps for others to reproduce the error** Ok, I've figured out how to reproduce. I needed to have Persistent Data enabled. I've attached a file that demonstrates the problem. 1. Render the scene once. Observe the different lightgroup render layers. The `Combined_Environment` layer has the default world illumination. ![image](/attachments/83cce85f-a51b-4f63-a206-2acfb611c20c) 2. Delete the Unused Light Group. ![image](/attachments/46ce68e1-6c18-4b19-a059-e57f098ce1d7) 3. Render the scene again. 4. Observe that the `Combined_Environment` is now black. Instead that pass is now part of `Combined_Green`. [117586 Light Group Delete Problem.blend](https://projects.blender.org/attachments/9f5cd1f8-b15b-4ef2-9070-20e6d55da96a) Anyway, given I cannot reproduce in a standalone file, I'm happy to analyse and debug the problem myself. Using the Python console, I've tried to look through all the data structures but cannot see anything that looks strange. Looking at the C++ code (BKE_view_layer_remove_lightgroup()) it only appears to change the active lightgroup, then remove the selected record from the linked list. Maybe some other part of the code is using a pointer to that linked list record - though doesn't seem logical that it would then render to a different lightgroup. I'll get the latest version of the code compiling and run it in the debugger tomorrow. However my gut feel is that the blend file is a bit messed-up or inconsistent - it's gone through many different Blender versions. Is there anything specific I should look at in Python or C++?
Mark Stead added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-01-28 11:15:45 +01:00
Author

Ok, I've figured out how to reproduce. I needed to have Persistent Data enabled. I've attached a file that demonstrates the problem.

  1. Render the scene once. Observe the different lightgroup render layers. The Combined_Environment layer has the default world illumination.
    image

  2. Delete the Unused Light Group.
    image

  3. Render the scene again.

  4. Observe that the Combined_Environment is now black. Instead that pass is now part of Combined_Green.

Another workaround would be to turn off/on Persistent Data.

In the code, Film::update_lightgroups() assigns a numeric index to each lightgroup. This successfully detects the change, and returns true.
The function Scene::device_update() applies some tag updates but not to the background.
Later Background::device_update() checks is_modified() (using socket_modified) and returns without updating any settings.
Specifically this code is not executed - which leaves dscene->data.background.lightgroup with the old (wrong) value.

/* Light group. */
auto it = scene->lightgroups.find(lightgroup);
if (it != scene->lightgroups.end()) {
  kbackground->lightgroup = it->second;
}
else {
  kbackground->lightgroup = LIGHTGROUP_NONE;
}

I've looked at why the code works successfully when you clear/set the World Light Group. That functionality is part of BlenderSync::sync_world() which appears to detect changes to the lightgroup name, and set the socket_modified flag. Of course in my scenario the Environment lightgroup name is unchanged, however the assigned index has changed.

Ok, I've figured out how to reproduce. I needed to have Persistent Data enabled. I've attached a file that demonstrates the problem. 1. Render the scene once. Observe the different lightgroup render layers. The `Combined_Environment` layer has the default world illumination. ![image](/attachments/83cce85f-a51b-4f63-a206-2acfb611c20c) 2. Delete the Unused Light Group. ![image](/attachments/46ce68e1-6c18-4b19-a059-e57f098ce1d7) 3. Render the scene again. 4. Observe that the `Combined_Environment` is now black. Instead that pass is now part of `Combined_Green`. Another workaround would be to turn off/on Persistent Data. In the code, `Film::update_lightgroups()` assigns a numeric index to each lightgroup. This successfully detects the change, and returns true. The function `Scene::device_update()` applies some tag updates but not to the background. Later `Background::device_update()` checks `is_modified()` (using `socket_modified`) and returns without updating any settings. Specifically this code is not executed - which leaves `dscene->data.background.lightgroup` with the old (wrong) value. ``` /* Light group. */ auto it = scene->lightgroups.find(lightgroup); if (it != scene->lightgroups.end()) { kbackground->lightgroup = it->second; } else { kbackground->lightgroup = LIGHTGROUP_NONE; } ``` I've looked at why the code works successfully when you clear/set the World Light Group. That functionality is part of `BlenderSync::sync_world()` which appears to detect changes to the lightgroup name, and set the `socket_modified` flag. Of course in my scenario the Environment lightgroup name is unchanged, however the assigned index has changed.
Member

Hi, thanks for the report. I can confirm.
cc @LukasStockner

Hi, thanks for the report. I can confirm. cc @LukasStockner
Pratik Borhade added
Module
Render & Cycles
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-02-01 07:01:31 +01:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-02-04 16:44:57 +01:00
Member

@MarkStead-2 Thanks for the extensive writeup!

@MarkStead-2 Thanks for the extensive writeup!
Member

@LukasStockner hi, can we backport the fix to 3.6/3.3 LTS? Looks straightforward to me

@LukasStockner hi, can we backport the fix to 3.6/3.3 LTS? Looks straightforward to me
Member

@LukasStockner hi, can we backport the fix to 3.6/3.3 LTS? Looks straightforward to me

Good point, thanks:

> @LukasStockner hi, can we backport the fix to 3.6/3.3 LTS? Looks straightforward to me Good point, thanks: - 3.6: 8508d6992b30756192626f4d8fad89af78cd0c3f - 3.3: 603b88f188aba1326bae5637885c2945611a1801
Member

Thanks for backporting them :D
For future, you can add commits in backporting list then Philipp/Thomas will backport them to 3.3/3.6LTS:

Thanks for backporting them :D For future, you can add commits in backporting list then Philipp/Thomas will backport them to 3.3/3.6LTS: - https://projects.blender.org/blender/blender/issues/100749 - https://projects.blender.org/blender/blender/issues/109399
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117586
No description provided.