Indirect Lighting Cache - there might be a bug

I’m using a weapon system with multiple parts(skel meshes) attached with bLightAttachmentAsGroup == true
When attaching it to a character the performance went really low and I figured out the reason.

  1. When creating a PrimitiveSceneInfo of a PrimitiveComponent, it sets its attachment root component as the LightingAttachmentRoot.

  2. When Indirect Lighting Cache is updated ( FIndirectLightingCache::UpdateCachePrimitive() ), it tries to find each PrimitiveSceneInfo’s attachment group root and use the root’s indirect lighting cache allocation. If it fails to find AttachmentParentAllocation, it calculates the Primitive’s indirect lighting allocation from the scratch.

  3. When the multipart-weapon is attached to a Character, all the part meshes’ attachment root is the collision capsule, which wouldn’t be rendered to a scene.

  4. It always fails to find the AttachmentParentAllocation of the meshes’ PrimitiveSceneInfo in 3. case and every parts calc their own cache allocation every frame. (Which takes a huge amount of time)

Is this a bug or there’s something wrong with my settings? Thanks for any advise.

I temporarily(since 4.5) modified the PrimitiveSceneInfo’s constructor to set the lighting attachment root the highest PrimitiveComponent in the hierarchy which is bUseLightAttachmentAsGroup enabled instead the AttachmentRoot to manually adjust the light attachment group and it works okay for me.

I just want to know what I think is right or not. Thanks for any advise here :slight_smile:

I think you kind of found an edge case here. yes the light attachment group is meant to make sure a group of meshes all light as one, but if the top parent is not a rendered object that falls back to the expensive path. I guess in a perfect world it would know to make a new lightingsample to use but I’m guessing this problem hasn’t come up enough yet.

What happens if you try to use one of the rendered chunks as an intermediate sub-root, and only check the bLightAttachmentAsGroup flag for that piece and not the top collision root? The tooltip does say that flag only works on roots so I am not completely sure if this will work.

Hi RyanB, sorry for the late answer. What I actually did was modifying GetAttachmentRoot() function to return the sub-root which is bLightAttachmentAsGroup == true. ( temporarily of course. it’s okay so far because the function is only used by indirect lighting cache related code)

The outcome, the sub-root makes it’s own attachment group and the group elements use the sub-root’s indirect lighting cache. Both visual outcome and performance show no problem.

In my opinion, if someone’s applying part assemble system to a character or it’s weapon meshes, all the meshes’ root will always be the collision capsule and therefore have this issue.
I’m using up to 15 meshes to a single weapon and can’t give up the benefit of using light attachment group.

Thanks for the answer RyanB and I expect there will be a modification later :slight_smile: