I've been digging into @UnrealEngine 5's Lumen yesterday to make it work with my voxels.
Here's what I learned along the way, if anyone's curious
(if I say something wrong please correct me :) )
I'll use the following scene as an example: a sphere with a colored emissive material, a white plane and no light whatsoever
For reference, here's how it looks without Lumen
The first thing we can do is disable screen space traces using r.Lumen.ScreenProbeGather.ScreenTraces 0
As you can see, the GI looks a lot worse with only the voxel grid (?) contribution
To know the mesh color/emissive/normal without sampling the material all the time, Lumen uses a surface cache system.
You can see the values stored in that cache using Show -> Visualize -> Lumen Scene
That cache works by rendering the mesh under different angles to an atlas. Each angle is defined using a "card": a rectangle onto which the mesh is rendered.
You can view these using r.Lumen.Visualize.CardPlacement 1
Below: the -X and +Z cards
The atlases are stored in Lumen.SceneAlbedo/SceneDepth/SceneNormal etc
You can use RenderDoc to view these, or the vis Lumen.SceneAlbedo command in UE
The cards are updated when the camera moves, as their resolutions are based on the distance from it.
You can use r.LumenScene.RecaptureEveryFrame 1 to force a recapture of all the cards in every frame
In our scene, the plane is rendered once and the sphere 6 times as expected
To find the color at a position, all we have to do now is find the best cards representing that position, project it onto them & read the values.
Lumen also reads the Depth atlas to ignore cards that would be occluded (I think 😄 )
@Slayemin Thank you! All of that makes a lot of sense to me. The screenshot looks very nice, but it doesn't feel real 🤔
With @voxelplugin I want to add a way to easily simulate geological events in a somewhat accurate way, so this is very helpful!
@Slayemin@voxelplugin "somewhat accurate" might be a bit strong here. For example, all it would do here is:
- you have a base brush to generate basalt columns
- you'd have a "tectonic displacement" brush that you'd use to generate the S shapes etc
You could then create multiple layers of these, and
@Slayemin@voxelplugin carve into them using some river brush or similar to expose all the different layers.
We could also imagine letting the player dig, exposing the multiple layers as they go down.
Even if we can't manage to get to the amazing visual quality Jedi Survivor rocks have, I feel
As you can see below, this is not screen space anymore but proper GI!
The generated distance fields are kind of a mess for cubes though. I tried to switch to cube instances to render the DF, but it's not working very well & is pretty slow.
I'll see if I can figure out a nice DF grid alignment to better represent the cubes.