Unlimited Light Sources with Clustered Forward Shading

Feedback on past, current, and future development.
User avatar
AnyOldName3
Posts: 2054
Joined: 26 Nov 2015, 03:25

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 11 Mar 2019, 14:53

To make OpenMW use all lights for everything, the quick thing to do would be to make the light list callback just enable every light and then tweak the shader so it can accept that many lights. It won't quite be the tidiest thing in the world and there'd be some redundant work, but it would be enough to get a ballpark estimate of whether implementing anything fancy and scaleable is worthwhile.
AnyOldName3, Master of Shadows

CMAugust
Posts: 261
Joined: 10 Jan 2016, 00:13

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 12 Mar 2019, 13:45

Yeah all I had tried in the past was set MAX_LIGHTS in the shader to a high number and obviously nothing good happened. It figures there's some hardcoded stuff to tweak as well.

User avatar
AnyOldName3
Posts: 2054
Joined: 26 Nov 2015, 03:25

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 12 Mar 2019, 14:31

The shader ignores any lights it's told to use beyond that number, but that doesn't mean the engine is bothering to tell it to use any other lights.

It might be a case of tweaking a couple of lines in the light manager, or it might involve moving away from glLight to a custom uniform depending on the maximum fixed function light count of modern GPUs.
AnyOldName3, Master of Shadows

CMAugust
Posts: 261
Joined: 10 Jan 2016, 00:13

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 12 Jun 2019, 01:58

3-month check-in: I'm still interested in updating this thread with examples of clustered shading in the wild as they're found, but there's also the matter of the suggested test using basic forward rendering. Any news on when or if this ballpark estimate can be conducted? I simply don't have the expertise to make the necessary code tweaks, whatever they may be.

User avatar
AnyOldName3
Posts: 2054
Joined: 26 Nov 2015, 03:25

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 12 Jun 2019, 14:32

It's all still on my to-do list.

With the amount of time it's taking to get around to stuff, it might genuinely be worth your while to learn some OpenGL if you haven't already. I know I've mentioned that before.
AnyOldName3, Master of Shadows

User avatar
wazabear
Posts: 13
Joined: 13 May 2020, 19:31
Gitlab profile: https://gitlab.com/glassmancody.info

Re: Unlimited Light Sources with Clustered Forward Shading

Post by wazabear » 21 Feb 2021, 07:39

AnyOldName3 wrote:
12 Mar 2019, 14:31
The shader ignores any lights it's told to use beyond that number, but that doesn't mean the engine is bothering to tell it to use any other lights.

It might be a case of tweaking a couple of lines in the light manager, or it might involve moving away from glLight to a custom uniform depending on the maximum fixed function light count of modern GPUs.
I went ahead and attempted this by doing just that. The gist of this patch is that I pass a point light count along with a UBO which contains an array holding the point light data. I pass the sun as a separate UBO with respect to a LightManager instance. All calls to gllight* are removed, I was not able to increase the max lights that gl_LightSource holds. Attempts at that simply yielded junk results. If you're interested here is the (very) WIP attempt. It doesn't crash or death spiral, so it's a start. The only change to the LightManager API right now is the special handling of adding a sun. I tried not too meddle too much with how we sort and cull the lights, so it's pretty much the same as it originally was.

The maximum number of lights is set to 16 and is configurable with a setting, let me know what you think of this.

Code: Select all

[Shaders]
max lights = 16

Here is CMAugust flying through the notoriously flickery Ald-Ruhn Mages Guild with the build.

User avatar
AnyOldName3
Posts: 2054
Joined: 26 Nov 2015, 03:25

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 21 Feb 2021, 16:00

Can you open a draft MR, please? It might be useful if I could review it a bit, but GitLab apparently won't do diffs across forks without an associated MR.
AnyOldName3, Master of Shadows

User avatar
wazabear
Posts: 13
Joined: 13 May 2020, 19:31
Gitlab profile: https://gitlab.com/glassmancody.info

Re: Unlimited Light Sources with Clustered Forward Shading

Post by wazabear » 21 Feb 2021, 22:54

AnyOldName3 wrote:
21 Feb 2021, 16:00
Can you open a draft MR, please? It might be useful if I could review it a bit, but GitLab apparently won't do diffs across forks without an associated MR.
Done. https://gitlab.com/OpenMW/openmw/-/merge_requests/618

User avatar
psi29a
Posts: 4990
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Unlimited Light Sources with Clustered Forward Shading

Post by psi29a » 22 Feb 2021, 10:59

You are a hero good sir. :)

Post Reply