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

Finalizing Shaders and Real-time Global Illumination Progress



I'm finalizing the shaders, and I was able to pack a lot of extra data into a single entity 4x4 matrix:

  • Orthogonal 4x4 matrix
  • RGBA color
  • Per-entity texture mapping offset (U/V), scale (U/V), and rotation
  • Bitwise entity flags for various settings
  • Linear and rotational velocity (for motion blur)
  • Skeleton ID

All of that info can be fit into just 64 bytes. The shaders now use a lot of snazzy new function like this:

void ExtractEntityInfo(in uint id, out mat4 mat, out vec4 color, out int skeletonID, out uint flags)
mat4 ExtractCameraProjectionMatrix(in uint cameraID, in int eye)

So all the storage / decompression routines are in one place instead of hard-coding a lot of matrix offset in different shaders.

A per-entity linear and angular velocity is being calculated and sent to the rendering thread. This is not related to the entity velocity in the physics simulation, although they will most often be the same. Rather, this is just a measure of the distance the entity moved since the last world render, so it will work with any motion, physics or otherwise.

In the video below, the linear velocity is being added to the camera position to help predict the region of the GI lighting area, so the camera stays roughly in the center as the GI updates. A single 128x128x128 volume texture is being used here, with a voxel size of 0.25 meters. In the final version, you probably want to use 3-4 stages, maybe using a 64x64x64 texture for each stage.

Performance of our voxel cone step tracing is quite good, with FPS in the mid-hundreds on a mid-range notebook GPU. The last big question is how to handle dynamic objects, particular fast-moving dynamic objects. I have some ideas but I'm not sure how hard this is going to be. My first attempt was slow and ugly. You can probably guess which dragon is static and which is dynamic:


It is a difficult problem. I would like the solution to be as cool as the rest of this system as I finish up this feature. Also, I think you will probably want to still use SSAO so dynamic objects blend into the GI lighting better.

Everyone should have access to fast real-time global illumination for games.

  • Like 8
  • Thanks 1


Recommended Comments

So the problem is not just moving objects affecting GI but even moving objects receiving GI from static objects?

Link to comment
5 hours ago, Genebris said:

So the problem is not just moving objects affecting GI but even moving objects receiving GI from static objects?

My inspiration came and I thought of a clever solution.

  • Like 1
Link to comment
11 hours ago, Josh said:

My inspiration came and I thought of a clever solution.

Hope this means I can avoid using SSAO. The effect looked gross in Leadwerks in-game imo.

Link to comment

SSAO in Ultra is a lot cleaner. I used a denoise filter to smooth the results:


  • Like 1
Link to comment

I found some SSAO shader years ago and it looks better than the built-in one. I don't remember where I found it.

Link to comment
4 hours ago, klepto2 said:

This can be done in LE as well ;)denoised_ssao.thumb.png.21ced6142f4e4a8d014027c9e2fbff7c.png

Ahh nice. If you don't mind sharing it, that would be great.

  • Like 1
Link to comment
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...