MegaLights feedback thread

not sure how the directional light fuzz is computed, but a cloud is basicly a fog volume or translucent plane if you were to do that. it cast it’s own shadow but does not scatter the light, you gotta fake the diffusion/diffraction of the clouds using the light angles. it does not do that automaticly. the trace is direct. and the light diffusion is defined by the angles.

if you were to put a cloud layer on top i guess you would have to get a vector from the hit point on the floor to the light and check the density/alpha at the intersection point with the cloud layer and use this to modulate the source angle. clouds are big. you would get the direct value at intersection point in say 400 meters high up. this would be the automatic way to do that. not sure if this could be done per pixel. i think not. it’s just a “broad” fake, but could do the trick for a small portion of focus. for wide shots or far range you gotta use the light function fake for the cloud shadows i’d guess. i don’t think there’s any “precise” way to blend all of that.

At a high level how does it work under the hood?
In order for me to use Lumens properly I had to have a base understanding of how it worked so I knew what to tune and what would make it not work. If you could clarify a bit on how MegaLight works we all could properly utilize it and make it shine without hitting on its weak areas.

Everything will explained be in docs. I’ll try to explain there everything as truthfully as possible, as I want everyone to understand how to use it and be able to make a good call whether he should use it for their production.

The general idea is that it’s like Next Event Estimation (direct lighting) in path tracing. Each pixel traces a fixed number of rays towards lights. If any of those rays hits a light then we compute its influence on a pixel and add that to the pixel’s color. At the end there’s a denoiser, which tries to keep image reasonable when we have more lights per pixel than available rays. There’s also some ray guiding so that instead of tracing rays randomly we trace them towards lights which seem to be more important.

The important part here is that it replaces both shadowing and direct lighting (BRDF evaluation, unshadowed light apply). Basically all deferred renderer lighting bits scattered around the frame are removed and replaced with a single MegaLights pass which does a single pass covering shadowing and lighting for opaque/translucent/fog. Though translucent isn’t supported yet :).

From the user perspective as lighting scenario gets harder (more lights having strong influence on a given pixel or large area lights casting shadows through complex geo) lighting quality decreases as denoiser need to do more work. At some point it will overwhelm the denoiser and you’ll see noise and similar artifacts.

To keep it working well try not to place lights inside geo and narrow their bounds as much as possible (spot angle, rect light barn door, attenuation range). There’s a debug view which shows which lights affect a given pixel, which turned out to be quite useful in the demo to find huge lights on the other side of the level or just buried inside walls, which won’t ever affect anything but still need to be computed by MegaLights.

Another limitation is BVH - you need to make sure that all important details are there and that they aren’t culled too early. BVH is shared with Lumen, so that’s not so bad as you tweak it once for both direct and indirect lighting. Some of the missing geo detail can be restored by screen space traces, but they do have their own limitations and artifacts. As we’re working on the HWRT path and its becoming more common things will improve here.

Finally everything goes through a denoiser, as lighting scenarios get harder or there’s more movement denoising gets less effective and you’ll see more artifacts. Denoising is certainly something we want to improve, as it has a few missing bits which are required to handle things like racing games or fast lighting changes.

Overall, it does require careful setup and has edge cases, but also in practice it does work surprisingly well given a tiny console budget if you know what you’re doing. I was really stressed out about it, but during demo production after a few pointers artists were really happy with the workflow and had lots of fun finding new places where they can add hundreds of lights. Many of those lights were excessive and likely would be removed in a real game, which doesn’t try to showcase new lighting tech. The entire demo was also made in 2 months by like 5 artists, so there isn’t any special demo magic and you should be able to recreate everything you saw there on your end.

15 Likes

On that note, a couple of potential bugs(?) I noticed:

  1. GeometryCollections are not added to the BVH even when Nanite Fallback is enabled (and r.RayTracing.Geometry.GeometryCollection is enabled). Works correctly for non-Nanite geo collections
  2. Megalights always seems to cast screen-traced shadows from geometry collections even when cast shadows is disabled on the geometry collection. I’m not sure if this is intentional since I imagine it could be useful for performance to disable RT cast shadows but still cast screen traced shadows on some objects. I only assume it’s a bug because regular static meshes don’t behave this way
Video

Using the Lumen debug view to visualize the BVH

I’m curious how screen traces fit into megalights in general, guessing they function similar to Lumen? (Minor performance optimization, resolving self-occlusion, picking up smaller details that might otherwise be lost?)

2 Likes

Maybe I shouldn’t have mentioned clouds. For practical reasons we don’t need to talk about clouds when it comes to area shadows projected by sun or other directional lights.
A sun seen through a thin cloud layer is sort of identical with a light which has a larger diameter. And the larger the dimension of the light, the softer the shadows projected by objects which are at some distance from the ground. As seen in the example picture.

1 Like

maybe we should stop tryna derail this, technically. the directional light aka sun lamp is not a part of megalights, yet. it uses it’s own very pass. and i think i gave you enough inspiration to get something rolling to cheat to get some form of soft shadow game visuals to work with.

ima chill :slight_smile:

1 Like


As this person said, Geometry collection shadows don’t seem to play nice with megalights unless you set Megalight Shadow Method to VSM, then it will cast shadows, but VSM cost a lot more. Any other setting casts these weird “short” shadows.

Overall, on a GTX1080, I know it doesn’t support HWRT but it does get some okay performance gains.
Visually looks really bad in motion though. The shadows look very pixelated and it feels very “smeary”.

Could we get a “megalight only” setting on light actors? Have the light actor only be used if megalights is enabled?

3 Likes

This is amazing. Thank you so so much for this. This will help us make it sing.
And yeah that demo was phenomenal.
Thanks to yalls efforts and the rest of the lighting dev team we’ve been able to use unreal on things like Dr Strange, Godzilla, Halo Series, RebelMoon, etc. Honestly Mega lights is going to let us push this even father so I really do appreciate all the hard work yall put in. Knowing where the edge cases where for Lumens and how to tune them was critical for all our projects so many thanks for this :slight_smile:

2 Likes

What I’m after is having a performant solution for multiple real-time shadowed lights in VR.

The forward renderer is quite performant, but has a limit on how many lights can affect an object and have (AFAIK) no caching of the shadowmaps. Quite often you will really need dynamic shadows only at specific points in gameplay, and the shadow calculation could be cached until some event occurs.

On the other hand the deferred renderer supports unlimited lights, but is slower, and again no caching of shadowmaps unless you enable VSM, which really only plays well with Nanite meshes, which again performance-wise are almost a hard no for VR games.

1 Like

Does anyone know if Megalights is in UEFN or when/if it will arrive to UEFN? Thanks!

Lumen already handles emissive lighting, so I’d assume megalights is only focused on punctual light sources (spot point rect etc.)

Does this mean translucent lighting/shadowing is going through a different pipeline when megalights is on, or that all translucent objects become unlit when MegaLights is enabled?

What I’m hearing is that one of the main optimization axes for megalights is keeping overlap of lights to an absolute minimum, even though you can now place and render many many more shadowed lights if they don’t intersect?

I have to say, I am absolutely loving Megalights for a lot of reasons, and while I’m definitely seeing some issues with temporal coherence, the fact that POM materials now integrate and light so naturally in the scene is a massive bonus. There may be edge cases, but it also eliminates hacks and limitations I’ve had on projects that have been a huge pain in the past.

Also, I can already guess the answer, but is there any chance the MegaLights demo will be released in some capacity to the public, so we can get an idea of how to best set up lighting under the MegaLights paradigm?

Could we use Light Function Material with Megalight? Im trying to use it for DMX Fixtures. Have a ton of Spotlight used LFM in my case.

Tested it with a light function on a point/spotlight and it works, no idea how it will affect the cost though

Is Megalights going to be the new “default” direct light system in UE going forward?
I noticed the feature already comes enabled in new projects in 5.5.0 preview1 even thought it’s still marked as experimental.

define “default”, but… yes… if you have a capable compute or raytracing gpu it’s probably enabled and you should experiment with and find a use for it, be it graphics.

raytracing has been around since the 20 series from nvidia. over 6 years have past. they are launching the 50 series next. 4th generation. sure… amd is lagging a lil bit, but it’s broadly available for the pc crowd and will come to consoles in a close gaming future. the ps5 pro has it. not a sony but a tech plug. :slight_smile:

I can’t see any way it isn’t. It has high quality and high scalability, it can use RTX cards but doesn’t have to (falling back to VSMs/SDFs), it can support high lights counts with full features. It’s better than every previous option in pretty much every way.

My thoughts exactly, I just wanted to hear it from the people working on the tech since they make the decision.

1 Like

Yeah, placing 4 relatively large overlapping area light sources nearby is a pretty bad case for moving objects, as it’s really hard to resolve that with 1 ray per pixel. Though there are also a few issues in the denoiser making it worse that it should look like. It’s certainly a challenge and something we need to improve on, hopefully some improvements will make to the 5.5 release.

Lit Volume Translucency objects become unlit and go through the normal (slower) pipeline). Something to fix in 5.6, as it requires a larger refactor of how translucency is lit in the engine.

Usually we release demos, but in this case we used third party content (as it was mentioned during the presentation), so not sure if this will happen.

Yeah, as long as they go through the new Light Function Atlas they should work.

Not much, as by default we evaluate ~1 light function per pixel.

At some point, but definitively not in this experimental state :). I just tried to create a blank C++ project with maximum preset in 5.5 and it seems to have MegaLights off. How did you create your project that you have MegaLights on by default?

4 Likes