Unlimited Light Sources with Clustered Forward Shading

Feedback on past, current, and future development.
User avatar
lysol
Posts: 1328
Joined: 26 Mar 2013, 01:48
Location: Sweden

Re: Unlimited Light Sources with Clustered Forward Shading

Post by lysol » 08 Mar 2019, 08:44

CMAugust wrote:
08 Mar 2019, 01:22
Assuming his LinkedIn is up to date, Ola Olsson is literally half an hour's drive from me. I think there's a decent sized bag lying around here somewhere :)
I couldn't even find Ola on linkedin, but can I then assume you'll reply to a "hej, bor du utanför Göteborg då eller?"?
Normal mapped texture replacers, exclusive for OpenMW:
My Nexus page

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 08 Mar 2019, 12:07

Not without Google Translate. In which case the answer is "Ja, väldigt långt utanför" :P

This talk in the OP makes clear he received his phd at Chalmers and is now a postdoc at the University of Queensland, Australia. Brisbane, to be specific. So I'll throw another shrimp on the barbie for him. :P


User avatar
lysol
Posts: 1328
Joined: 26 Mar 2013, 01:48
Location: Sweden

Re: Unlimited Light Sources with Clustered Forward Shading

Post by lysol » 08 Mar 2019, 13:39

CMAugust wrote:
08 Mar 2019, 12:07
Not without Google Translate. In which case the answer is "Ja, väldigt långt utanför" :P

This talk in the OP makes clear he received his phd at Chalmers and is now a postdoc at the University of Queensland, Australia. Brisbane, to be specific. So I'll throw another shrimp on the barbie for him. :P
Oh. Nevermind then. :lol:
Normal mapped texture replacers, exclusive for OpenMW:
My Nexus page

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 09 Mar 2019, 15:06

@psi29a: lol

@AnyOldName3: let's assume for the moment that Ola Olsson doesn't get back to me. Leaving aside the many-cubemapped-shadows-with-virtual-texturing as a separate issue, what about the clustered forward shading itself? That at least sounds much less involved and perhaps within the realm of possibility.

I'd also be interested to know what sort of changes the original assets would need in order to fulfil the batching prerequisites you talk about. There is an interest in asset optimisation in the modding community, and that sort of insight could be very helpful for a future project.

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 09 Mar 2019, 16:54

As you probably know, Morrowind uses lots of tiny meshes, probably in part because it came from an era when GPUs were slower than CPUs, so draw calls weren't a concern, but drawing excess polygons was. There are a few problems that make batching (automatic or manual) difficult:
  • The thing we've been talking about a lot in this thread about binding lights per object, so lighting being better when all objects are small so the light assignment is finely grained. This would be solved by one of the many use-all-lights solutions mentioned here.
  • Pretty much anything can be added or removed at any time by a script, so it has to be possible to un-batch things with little to no warning.
  • Lots of things use tiny textures with only one thing on them, and anything in one batch has to use the same texture. This is solvable with atlassing, but only in cases where UV coordinates are in the 0-1 range, as implementing wrapping or clamping in the shader can get complicated.
  • Anything with alpha-blending can't be batched or it can't be depth-sorted.
  • Possibly other things that I can't remember off the top of my head.
I think a good test to do now would be to see if basic forward rendering is reasonably fast with the number of lights Morrowind has. In the medium term, we don't need to support 100,000 lights at once as I doubt Morrowind ever has much over a hundred at the same time, and the extra overhead of tiling or clustering lights might be more than the overhead of just shading everything.
AnyOldName3, Master of Shadows

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 09 Mar 2019, 22:14

"Just shade everything" test - sounds like a plan. That's the most straightforward of all to code as well I expect. Your talk about needing to unbatch things is something I've thought about a lot too, hopefully that is possible.

It sounds like Project Atlas is ticking all the boxes as far as mesh optimisation goes. It's being extended all the time and is likely to be a "must have" mod for future engine-side batching.

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by AnyOldName3 » 10 Mar 2019, 01:12

Atlassing doesn't absolutely have to be done manually - doing it automatically is basically what id Tech engines call Megatextures, the fancy new feature that they added to id Tech 5, but doing it like that is easier with newer OpenGL versions. Doing it automatically has some advantages, but makes the engine more complicated and isn't necessarily something that can be done easily with OSG.
AnyOldName3, Master of Shadows

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 10 Mar 2019, 01:31

Yeah, systemic solutions are awesome. But it's good to know there's a manual option if it doesn't happen. :)

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

Re: Unlimited Light Sources with Clustered Forward Shading

Post by CMAugust » 11 Mar 2019, 13:41

Some more resources for the list. Adding the webpage for Volume Tiled Forward Shading by Jeremiah van Oosten, which I should have provided along with the video. It contains links to his thesis, powerpoint presentation and source code.

The Open Source engine AnKi 3D uses Cluster based deferred shading. There was also a forum thread about it.

And for an alternative viewpoint, a blog entry titled Simple Alternative to Clustered Shading for Thousands of Lights by Luke Mamacos. His technique, BVH Accelerated Shading, is claimed to be "very easy to implement, minimally invasive on your render pipeline" along with other benefits, with the con being "requires tree traversal which has logarithmic complexity in the number of lights, where clustered shading with a 3d texture is more or less a constant lookup time". Ola Olsson appears in the comments and makes a few interesting points of his own, including that the setup cost for Clustered Shading isn't all that.
AnyOldName3 wrote:
09 Mar 2019, 16:54
I think a good test to do now would be to see if basic forward rendering is reasonably fast with the number of lights Morrowind has.
How does one actually test this, anyway?

Post Reply