Jump to content

Clustered Forward Rendering


Josh

10,604 views

 Share

I decided I want the voxel GI system to render direct lighting on the graphics card, so in order to make that happen I need working lights and shadows in the new renderer. Tomorrow I am going to start my implementation of clustered forward rendering to replace the deferred renderer in the next game engine. This works by dividing the camera frustum up into sectors, as shown below.

frustum.png.65b666f3b7fe602814334941ea6aa92b.png

A list of visible lights for each cell is sent to the GPU. If you think about it, this is really another voxel algorithm. The whole idea of voxels is that it costs too much processing power to calculate something expensive for each pixel, so lets calculate it for a 3D grid of volumes and then grab those settings for each pixel inside the volume. In the case of real-time global illumination, we also do a linear blend between the values based on the pixel position.

Here's a diagram of a spherical point light lying on the frustum.

frustum2.png.807544ac8a937cdaaa1e85380649e7cc.png

But if we skew the frustum so that the lines are all perpendicular, we can see this is actually a voxel problem, and it's the light that is warped in a funny way, not the frustum. I couldn't figure out how to warp the sphere exactly right, but it's something like this.

frustum3.png.e4caea9ffae789eeae8a3c0289e22300.png

For each pixel that is rendered, you transform it to the perpendicular grid above and perform lighting using only the lights that are present in that cell. This tecnnique seems like a no-brainer, but it would not have been possible to do this when our deferred renderer first came to be. GPUs were not nearly as flexible back then as they are now, and things like a variable-length for loop would be a big no-no.

183283228.jpg.30a78924ea64496599961ee968d70e98.jpg

Well, something else interesting occurred to me while I was going over this. The new engine is an ambitious project, with a brand new editor to be built from scratch. That's going to take a lot of time. There's a lot of interest in the features I am working on now, and I would like to get them out sooner rather than later. It might be possible to incorporate the clustered forward renderer and voxel GI into Leadwerks Game Engine 4 (at which point I would probably call it 5) but keep the old engine architecture. This would give Leadwerks a big performance boost (not as big as the new architecture, but still probably 2-3x in some situations). The visuals would also make a giant leap forward into the future. And it might even be possible to release in time for Christmas. All the shaders would have to be modified, but if you just updated your project everything would run in the new Leadwerks Game Engine 5 without any problem. This would need to be a paid update, probably with a new app ID on Steam. The current Workshop contents would not be accessible from the new app ID, but we have the Marketplace for that.

This would also have the benefit of bringing the editor up to date with the new rendering methods, which would mean the existing editor could be used seamlessly with the new engine. We presently can't do this because the new engine and Leadwerks 4 use completely different shaders.

This could solve a lot of problems and give us a much smoother transition from here to where we want to go in the future:

  1. Leadwerks Game Engine 4 (deferred rendering, existing editor) [Now]
  2. Leadwerks Game Engine 5 (clustered forward rendering, real-time GI, PBR materials, existing architecture, existing editor) [Christmas 2018]
  3. Turbo Game Engine (clustered forward rendering, new architecture,  new editor) [April 2020]

I just thought of this a couple hours ago, so I can't say right now for sure if we will go this route, but we will see. No matter what, I want to get a version 4.6 out first with a few features and fixes.

You can read more about clustered forward rendering in this article

  • Like 1
  • Sad 1
 Share

7 Comments


Recommended Comments

1. I feel like I asked this already but does a clustered forward renderer add to the dev by having to be lightmap steps like older forward renderers did? Part of the cool part about the deferred rendering I always thought was you just put in a light and ran the game and didn't have to worry about that stuff wher ewith forward renderers you had to do the light baking step which always took a decent amount of time with big scenes.

2. Does a clustered forward renderer run on mobile? Not that is the focus just curious if it's a nice side effect?

Link to comment
9 minutes ago, Rick said:

1. I feel like I asked this already but does a clustered forward renderer add to the dev by having to be lightmap steps like older forward renderers did? Part of the cool part about the deferred rendering I always thought was you just put in a light and ran the game and didn't have to worry about that stuff wher ewith forward renderers you had to do the light baking step which always took a decent amount of time with big scenes.

2. Does a clustered forward renderer run on mobile? Not that is the focus just curious if it's a nice side effect?

It’s basically just like deferred lighting without the heavy overhead. I’m not sure how well the branching logic would run on mobile graphics, but it would work.

Link to comment

I have mix feelings about the new approach on the LE5 idea. It makes totally sense to support Leadwerks as Turbo is developing in the background. Totally focusing on the future now will make Leadwerks seem like abandon ware (although not really.)

Leadwerks 3.1 - 4.x was designed to work with the Steam ecosystem which is a huge mess beyond belief. Since this site has steam intergration, you could resell LE5 at the $99/$199 price, the subscription model (good idea to test this sooner) and offer existing owners of LE4 on Steam a discounted price. I used to be a big Steam supporter, but due to recent events, I encourage people to go elsewhere.

As for the features of this LE5, I recommend actually porting the new architecture for performance instead of new visuals. I always have and still have performance issues with Leadwerks to a point I shelved my projects in wait of Turbo and free time. Porting the architecture will also allow you to see if it will hold up in real world use. I personally don't care how you end up making LE faster if porting the architecture is a project within itself, but LE should see a performance update. The Zone should run better then it currently does in my opinion.

In the end, it's your call as always. ?

  • Sad 1
Link to comment
7 hours ago, reepblue said:

I have mix feelings about the new approach on the LE5 idea. It makes totally sense to support Leadwerks as Turbo is developing in the background. Totally focusing on the future now will make Leadwerks seem like abandon ware (although not really.)

Leadwerks 3.1 - 4.x was designed to work with the Steam ecosystem which is a huge mess beyond belief. Since this site has steam intergration, you could resell LE5 at the $99/$199 price, the subscription model (good idea to test this sooner) and offer existing owners of LE4 on Steam a discounted price. I used to be a big Steam supporter, but due to recent events, I encourage people to go elsewhere.

As for the features of this LE5, I recommend actually porting the new architecture for performance instead of new visuals. I always have and still have performance issues with Leadwerks to a point I shelved my projects in wait of Turbo and free time. Porting the architecture will also allow you to see if it will hold up in real world use. I personally don't care how you end up making LE faster if porting the architecture is a project within itself, but LE should see a performance update. The Zone should run better then it currently does in my opinion.

In the end, it's your call as always. ?

The new architecture relies on smart pointers. It's incompatible with the current API, Lua binding code, and editor.

I think this new rendering approach will give a significant performance increase, particularly on low to mid-level hardware (like I believe you have).

Link to comment

I got rid of my older machine with the 750ti. My Windows machine has the RX480 while my Linux box as a cute little 1050ti. When I get a chance, I'll update my hardware profile. ?

Granted, I didn't play with LE on my RX much outside of VR. Noticed a performance boost on the AI and Events map with visual odds that I took was more on AMDs part. I recall not being happy with The Zone and pin pointed it to do with the amount of objects in the cameras view cone while I was trying to get the map to work with VR.

I understand and respect you not wanting to back engineer the engine, and that's cool. Use your new knowledge from Turbo to make Leadwerks faster and I'll be happy to give it another look  Maybe you can also lower the overhead with other classes (like bones) while you're in there as well. I'm eager await what you have in mind and end up doing.

  • Upvote 1
Link to comment
8 hours ago, martyj said:

Will there be an option to have Turbo out sooner for C++ folk?

The beta for C++ is available now, but there's not a lot of functionality yet.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...