Cannot visualize a lens flare in large worlds

Hi,
I’m developing a space sim, and I’m trying to build a 1:1 scale environment using large worlds.
Using 1:1 scale is a non-negotiable requirement :slight_smile:
Everything works fine, planet placement, movement, skybox.

For visual effect, I’d like to improve the standard lens flare, especially for the main star of the solar system.
I see that this is usually done by using certain (complex) materials, for example in this package found on the marketplace: https://www.unrealengine.com/marketplace/en-US/product/lens-flares

The custom lens flares in this package work perfectly… until a certain distance.
They seem to work for about 100km or so, which is a perfectly adequate distance for most games, but for large worlds this does not work at all.
This issue is a limitation of the engine. It is confirmed also by the author of the package (see the “Questions” section).
I don’t know which material functions are the limiting factor, but likely some functions are using still 32bit floats instead of 64bit doubles. I tried to play around with the material, but with no luck.

I would need these lens flares to work for an infinite distance.

I tried to fake the effect by placing the lens flare attached to a movable object in between the player camera and the star, but the distances are so great that this object takes a non-zero time to update in the correct position, causing the effect to look very silly :slight_smile:

I did not try particles yet, but they should have the same issue. The underlying material would not get visualized at far distance.

So the question is: how to make a custom lens flare when using Large Worlds?

Thanks for any input!

For the record: the material I’m using for the lens flare is currently a Surface, Additive, Unlit.

I’ll write it here for the record, in case someone finds this thread while having the same issue.

It is an engine limitation, in particular the SceneDepth node/function.

My speculation, as a non-expert:
The SceneDepth appears to have still “low” (not sure whether 16bit, 32bit…) accuracy, while in Large Worlds the coordinates need to be expressed in 64bit doubles. Therefore they should require a larger SceneDepth buffer than used previously.
I can imagine that at distances above 1000km the SceneDepth node/function does not give anymore a good/valid result, and the material doesn’t work anymore and is just not rendered.
Funnily enough, a material which depends on SceneDepth can be visualized anyway with some editing of the material nodes, but it will then always end up in front of any other object, as SceneDepth is required to give the engine the instruction of whether there is another object in between the camera and the material being rendered.

Hopefully someone might find a workaround for this, but I see it very unlikely, unless the UE developers decide to improve the SceneDepth buffer and make it able to support Large Worlds for real :slight_smile:

2 Likes