Calculating the amount of light rendered on mesh as a number

I originally posted this question on the AnswerHub, but I think it’s more of a discussion question than a simple question and answer, so I’m reposting here. (Calculate amount of light as number - Rendering - Unreal Engine Forums)

Question: Would it be possible to dig into the source of the renderer and come out with a number that describes how much light is being cast on an object? I would want that number to be available per tick at run time.

The response I received suggested that I could run an occlusion query from each light’s point of view to see how many pixels per object were visible. Presumably I could multiply that by the intensity of the light to be a value. As a theory, is there agreement that this could work?

I started off knowing zilch about the rendering code, so I would appreciate any specific suggestions on how this might be accomplished.

In the meantime, I’ve started digging through the rendering source, and I’ll post here what I think I’ve learned so far. Perhaps a kind soul could provide more general direction, as well.

It looks like the main function for rendering the shadows is FDeferredShadingSceneRenderer::Render(). I’m not sure from where this function is called, yet. The Render function has calls to BeginOcclusionTests() and RenderLights() which are in SceneOcclusion.cpp and LightRendering.cpp respectively. I think the occlusion test iterates through the lights and runs a shadow occlusion query (the BeginRenderQuery function from the RHICmdList object. I tried to dig into this but it looks highly complex). Although I don’t understand for sure, presumably the resulting information is passed back through RHICmdList? That object is always passed by reference and seems to hold a hell of a lot of information. The RenderLights function boils down to the RenderLight function. The RenderLights function boils down to the RenderLight function. The RenderLight function calls functions (from ShadowRendering and other places) for DrawRectangle, DrawSphere, DrawCone, which presumably determine the area the light is affecting.
But I’m not sure where to go from here.

I’ll keep spending hours trying to build together these piece in my head, but if someone more experienced with the code would be interested in helping, that would be greatly appreciated!

Thanks,
Zach

Hi, I have no answers, but I was wondering if you ever managed this (and how). I realise that this is a very old post, but I cannot find any others on the same subject. Thanks in advance.