Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Three improvements I made to Leadwerks Game Engine 5 today


Josh

3,038 views

First, I was experiencing some crashes due to race conditions. These are very very bad, and very hard to track down. The problems were being caused by reuse of thread returned objects. Basically, a thread performs some tasks, returns an object with all the processed data, and then once the parent thread is done with that data it is returned to a pool of objects available for the thread to use. This is pretty complicated, and I found that when I switched to just creating a new return object each time the thread runs, the speed was the same as before. So the system is nice and stable now. I tend to be very careful about sharing data between threads and only doing it in a prescribed manner (through a command buffer and using separate objects) and I will continue to use this approach.

Second, I added a built-in mouselook mode for cameras. You can call Camera::SetFreeLook(true) and get a automatic mouse controls that make the camera look around. I am not doing this to make things easier, I am doing it because it allows fast snappy mouse looking even if your game is running at a lower frequency. So you can run your game at 30 hz, giving you 33 milliseconds for all your game code to complete, but it will feel like 60+ hz because the mouse will update in the rendering thread, which is running at a faster speed. The same idea will be used to eliminate head movement latency in VR.

Finally, I switched the instance indexes that are uploaded to the GPU from integers to 16-bit unsigned shorts. You can still have up to 131072 instances of a single object, because the engine will store instances above and below 65536 in two separate batches, and then send an integer to the shader to add to the instance index. Again, this is an example of a hard limit I am putting in place in order to make a more structured and faster performing engine, but it seems like the constraints I am setting so far are unlikely to even be noticed.

Animation is working great, and performance is just as fast as before I started adding it, so things are looking good. Here's a funny picture of me trying to add things to the renderer to slow it down and failing :D:

Image1.thumb.jpg.1d49aa6bb1e108e1784c0f2964ab1036.jpg

I'm not sure what I will tackle next. I could work on threading the physics and AI, spend some time exploring new graphics options, or implement lighting so that we have a basic usable version of Leadwerks 5 for indoors games. What would you like to see next in the Leadwerks Game Engine 5 Alpha?

  • Sad 1

29 Comments


Recommended Comments



5 hours ago, gamecreator said:

Same.  Curious if we'll be able to do something like this again: https://www.youtube.com/watch?v=V4uh5j4BM7w

I don't understand. What does that video do that you can't do right now?

11 hours ago, tournamentdan said:

Have you decided to move forward to PBR?

I've looked into it, and here is what "PBR" means:

  • A texture lookup is used for light reflection instead of a dot product equation.
  • A cubemap is always in use, with mipmaps. The "roughness" value in a material or texture corresponds to the mip level to use in the cubemap lookup.
  • There's a user-adjustable value for the Fresnel reflection value.

As always, good art will look good and bad art will look bad.

9 hours ago, SpiderPig said:

I would like to see your approach to lighting.  Very interested to see how it effects performance.

Direct lighting will be the same as Leadwerks 4, although I might add some new light types. There's two approaches I could take with indirect lighting. One is to combine SSR and environment probes. This is what Doom 2016 does and it looks great. There are also some real-time GI techniques that are now becoming possible to do in realtime on high-end hardware. I am investigating this as well.

Link to comment
18 minutes ago, Josh said:

I don't understand. What does that video do that you can't do right now?

I don't think spotlights even work on vegetation now, do they?

Link to comment
10 minutes ago, gamecreator said:

I don't think spotlights even work on vegetation now, do they?

Ah, I see. Point and spotlight shadows are skipped on vegetation to save performance. The vegetation system is pretty heavy but is good at rendering millions of instances. I don't know if this will change, I have not thought about it really.

Link to comment
Quote

There are also some real-time GI techniques that are now becoming possible to do in realtime on high-end hardware. I am investigating this as well.

Looking forward to hearing more on this.

 

On the subject of lighting, are there techniques around that allow infinite distance shadow rendering?

Link to comment
5 hours ago, Josh said:

 

I've looked into it, and here is what "PBR" means:

  • A texture lookup is used for light reflection instead of a dot product equation.
  • A cubemap is always in use, with mipmaps. The "roughness" value in a material or texture corresponds to the mip level to use in the cubemap lookup.
  • There's a user-adjustable value for the Fresnel reflection value.

As always, good art will look good and bad art will look bad.

 

It also means that on the content creator side(for pbr). It is about a hundred times easier to create good art.

Link to comment
3 hours ago, SpiderPig said:

Looking forward to hearing more on this.

On the subject of lighting, are there techniques around that allow infinite distance shadow rendering?

Raytracing.

It also means that on the content creator side(for pbr). It is about a hundred times easier to create good art.

Do you have any materials you would like me to try?

Link to comment
23 minutes ago, Josh said:

 

 

25 minutes ago, Josh said:

Do you have any materials you would like me to try?

I am in Puerto Rico right now away from my computer. Let me head home and I can send you several.

Link to comment
17 hours ago, tournamentdan said:

Have you decided to move forward to PBR?

You are absolutely right. PBR is the nextgen rendering solution and it is more realistic than traditional rendering.

This is a nice page to compare them: https://warthunder.com/en/devblog/current/806 Slide the red line in the middle of the pictures below right and left to see the difference both them.

Link to comment
5 minutes ago, Berken said:

You are absolutely right. PBR is the nextgen rendering solution and it is more realistic than traditional rendering.

This is a nice page to compare them to: https://warthunder.com/en/devblog/current/806 Slide the red line in the middle of the pictures below right and left to see the difference both them.

Do you have any PBR materials you would like me to try?

Link to comment

For me PBR provides a standardised consistency regardless of lightning environment. I know my assets will look similar regardless of the 3d application/engine they are being rendered in.

Link to comment
13 minutes ago, Josh said:

Do you have any PBR materials you would like me to try?

You can try these materials. A brick and a rusted metal.

PBRs.rar

  • Thanks 1
Link to comment
6 hours ago, aiaf said:

Exploring new graphics options and more lights :)

I am looking into a CPU-based voxel GI system right now. This can be done on the GPU, but it has terrible framerates even on high-end hardware. If I dedicate a couple of CPU threads to this in the background they could just send the result to the GPU whenever they are finished. I think the performance in the GI update would be nice and fast with a sparse voxel octree but dynamic reflections might lag behind too much. I'm thinking if I cache static geometry and pre-rasterize all dynamic models, the updates should be pretty fast, but I don't really know until I try it. The GI update would be dealing with only voxel data after the first rasterization, and would not be re-rasterizing everything over and over each frame. I could store two GI data sets in the GPU and do a smooth transition between them as new updates are fed to the GPU.

I think the problem will parallelize well and we do have 18 core CPUs in existence today.

Also, rasterizing triangles on the GPU into a 3D texture is extremely complicated and uses a bunch of new techniques I have never used. This by itself is not a good reason not to do it, but I am not very eager to spend two weeks implementing that when I already know it is too slow for practical use.

Link to comment
2 minutes ago, martyj said:

When will we see textured models in the LE5 demos?

Bwahaha, someday. It's just not a priority right now. :D

Link to comment
9 hours ago, Josh said:

Ah, I see. Point and spotlight shadows are skipped on vegetation to save performance. The vegetation system is pretty heavy but is good at rendering millions of instances. I don't know if this will change, I have not thought about it really.

I understand that it would be a challenge.  I hope you're up for it.  :)

lantern_forest_by_retrolex.jpg

  • Like 1
Link to comment

Optimize lighting and shadows and fix/reduce shadow banding. 

LE5 is already better than LE4 due to it not slowing down after a few objects and skeletons. Looking forward to the final product.

Link to comment

Lighting and materials are closely linked because the material needs some kind of ambient light to reflect. This can come in the form of a cubemap or global illumination.

I think I will pursue the GI thing and perhaps the next update to the library can have lighting with GI and PBR materials working. It won't include terrain, particles, sprites, GUI, etc. but it will be usable.

  • Like 2
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.

Facebook Twitter Youtube Github Steam
×
×
  • Create New...