Learn how to use new GPU lightmaping in Unreal Engine

Michal Franczak 2020-10-07 09:50 tutorial  > Unreal Engine  > modeling

In the latest Unreal Engine version, Epic introduced GPU lightmapping, greatly increasing the speed of creating photorealistic environments.

If you want to have realistic lighting in Unreal Engine you have two options (without plugins like external rendering engines - V-Ray, Octane, etc.). One is to bake all your static lighting into lightmaps. The second is to use real-time GI and reflextions using raytracing. The second method is fresh and new but requires using top-tier GPU cards and even with them it has its own limitations. We are not there yet, when it comes to raytracing GPU power in re-creating great global illumination. But it is still great choice for reflections, ambient occlussion, etc. And in the incoming years it will be more and more important method for achieving photorealism in games and real-time architectural visualizations. But today, let's focus on the other, older method - baking lightmaps.

Lightmaps are special textures that are used for simulating global illumination. They can work with static objects only - thius is a big limitation for games, but it is not a very big problem for architecture, which is mostly focused on visualizing non-moving objects. Baking lightmaps can give wonderful results and let you make camera animations in photo-realistic envronments in a fraction of time that wopuld be needed when we would use classic path tracing rendering engine. It is also great for VR.

But baking lightmaps using CPU is very time-consuming. Achieving highest possible quality takes sometimes days. It's much too much for working professional. That's where GPU lightmap baking kicks in. A more than a year ago an invidual called Luoshang introduced his own plugin for Unreal Engine, which used GPU for baking lightmaps. It was an instant hit. This solution was about 20 times faster than regular CPU baking, we wrote about it in a separate article on Evermotion and still recommend to check it out.

Epic wasn't blind and sooner than later started cooperation with Luoshang and the work on native GPU lightmap baking has begun. Several months have passed and... with the hot, latest Unreal Engine 4.26 Preview version we finally can check it out! Let's see how to use this method in its current state.

 

1_9

There are several prerequisites to enable GPU lightmap baking in Unreal Engine 4.26. You need to use tha latest Windows 10 version. Update if necessary. Then, install the latest version of Unreal from your Epic launcher. Then, create a new architectural project and go to Project settings. Enable "Virtual Texture support" and "Virtual Texture Lightmaps".

 

2_9

Also enable GPU Lightmass plugin in Editor > Plugins menu.

 

3_9

Change default RHI to "Directx 12".

 

4_8

Enable ray-tracing. Restart the editor, wait for shaders to recompile. It can take some time.

 

5_8

Default Unreal Engine architectural exterior scene looks like this. At the beginning it is lit by movable lights - no real global illumination, no lightmaps, no ray-tracing. We need to change it.

 

6a

Go to SkyLight in the Outliner and change it to static. You can also increase Cubemap resolution to 256.

 

6b

Select Directional Light and make it static too.

 

6c

Change SkyAtmosphere to static.

 

7_7

Go to Build menu and press a little arrow near the icon. Select GPU Lightmass from the menu. You can get a warning that GPU Lightmass works in slow mode if the viewport is refreshed in real-time and at the full speed when real-time is off. To turn off real-time viewport refreshing press "CTRL-R". You will see "Realtime off" icon appear in the top left corner of the viewport. Now we can render. Default settings are good for the start.

 

1shot

The first baking result comes in seconds, but the quality is horrible. The main reason is default lightmap size of our models. We need to ijncrease it.

 

8_8

You can increase lightmap size for all models at once, just select them and find "Lighting" paragraph in object details panel. Change it to 256 or 512 for small and medium sized objects and to 1024 or 2048 for bigger ones.

 

2shot

Second shot is better- we increased our lightmaps a bit, shadows are more accurate, let's increase it further.

 

3shot

This time baking took 3 minutes. Still it's pretty fast, quality is higher than before. No you can clear the level from default assets, import your scene from your 3d software through Datasmith or Send to Unreal Blender plugin and test it further. Enjoy!

 

 

Author: Michal Franczak Editor: Michał Franczak
Tags: unreal ue4 gpu ue4 gpu
You may also like...
Unreal Engine  - free direct access for students

Unreal Engine - free direct access for students

Unreal Engine 4 is now free for students through Github.
×

LEAVE A COMMENT

You need to be logged in to leave a comment. Don't have account? Register now.
  • ul. Przedzalniana 8, 15-688 Bialystok, POLAND