Runtime Lightmap Generation

Today we’ve launched a new feature which we’ve been beta testing for a while.

Runtime Lightmap Generation

With runtime lightmap generation you can enable lightmap baking directly on light components from with in the editor. The lightmaps are generated in the browser at runtime so you avoid potentially costly texture downloads.

READ MORE

4 Likes

Awesome feature, guys!
Will be testing it out in upcoming days, expect some feedback :wink:

And runtime generation is a MAJOR feature. Not only that reduces total download size dramatically, but also can be very useful for procedurally generated levels.

Initial feedback:

  1. On simple scenes it seems to work great. Haven’t tried complex ones, but Sponza demo speaks for itself.

  2. Since lightmaps are baked at runtime using special shader, it’s relatively easy to get shadowmap bias artifacts. On small shadowmap resolutions they show up as random texel noise, on big ones - as lines. But it’s fixable by tweaking bias and stuff.

  3. Baking workflow is a little bit confusing. At first I didn’t know that ‘Bake Lightmaps’ button exists in the main menu, so I had some initial problems with everything being dark. Second, when you want to change some light and rebake, you need to have ‘Affect LIghtmapped’ checked on it, so when you go from Baked to Dynamic state for this light, you could see your adjustments in realtime. When you go back to Baked state, this ‘Affect Lightmapped’ becomes grayed out, so it may be confusing for some people. But actually, incremental lightmapping can be done surprisingly well with this approach. Add base lights -> bake -> add secondary -> bake -> add fake GI -> bake, etc.

  4. Would be really great to have some sort of static AO calculated in the lightmapping shader as well. It’s usually possible to create a pleasing GI approximation with additional lights, but AO can’t be faked, unfortunately. Without it scenes can look bland.

Thanks for feedback @underlight.

Regarding #2, it always will be a trouble, for baked and non-baked lights unfortunately. So yes, tweaking bias and normal offset is the way to go.

About #3, there is a button on left panel, that has “Auto Rebake” checkbox. This might work for you, and should rebake when relevant properties and stuff is changed. Additionally you can use a hotkey Ctrl/Cmnd + B for rebaking at any time you need :slight_smile:

And #4. Global Illumination and Ambient Occlusion are the things we really want, indeed. But in comparison to lightmaps, those will have to be baked in advance, into smaller resolution textures. GI needs way small texture size, but takes way longer to bake. We are looking into option of baking it in Editor into atlas textures, and they will be downloaded on loading times. As GI will be in atlases and way smaller resolution, it wont be that big comparing to lightmaps.
AO though, needs good resolution usually, but we always do decent R&D to find what works and what not, and trying to find best for most cases solutions. We surely will come up with something :smile:

Thanks for testing again. If you will make any cool and pretty demo, feel free to share it around!

@max

I was thinking rather about some sort of multipass SSAO, but rendered from light’s perspective (with depth tricks and such) and then applied to visible lightmap texels. Yeah, it’s far from ideal approach, and resulting AO would be visible only in areas lit by some baked light, but that could actually work, I believe. What do you think?

As for testing - sure, will try to test it out on more advanced scenes in upcoming days!

Ambient Occlusion actually affects mostly stuff in shadow, rather than in light.
And rendering it from perspective of light, would make it probably a little bit weird, as there will be AO in corners where stuff is lit, and not in shadow.
Although visually it should be more opposite, where more AO is apparent in darker areas, while less in bright.

So we need a solution that is not light relevant, but simply global to scene and environment. That is achievable by many ways, and finding an efficient and fast approach - is a challenge we need to solve :slight_smile:

Testing simple objects and unwrapping:

https://playcanv.as/p/TTqEEnC6

Chair model: https://www.assetstore.unity3d.com/en/#!/content/23556
Diffuse map: 1024x1024 with prebaked AO, no Normal and Specular maps
Lightmapping: 5 directional lights (for extra soft shadow) + 3 point lights
Tonemapping: Filmic, exposure 2

Some feedback:

  1. UV1 unwrapping is still far from ideal, unfortunately. Generated lightmap was showing artifacts until I cranked the size multiplier up to 64, resulting in 512 size. Any ideas on how to deal with it? :wink:

  2. While transitioning from dynamic to baked, there is no 1:1 parity in intensity. Dynamic lights seem to be 10-20% brighter compared to when they’re baked. Seems like it’s a downside of PBR material and it’s approximated energy conservation?

Thanks for tests!

Indeed, writing proprietary UV1 unwrapper, can prove to be very very challenging :slight_smile: some of decent 3D authoring tools do as bad job today. So our UV1 unwrapper is just a convenience feature. If project has an artist, they will unwrap it for best results.

Is it related to actual light information, or that specularity is not yet available for lightmaps, so in dynamic you have specularity and in baked not, so it looks different.
I can see very subtle difference, will have to look a bit closer to that.

And BTW, it is always better to supply AO map as separate texture, as it is mixed with light and specularity in a different way, affecting it more in a PBR manner.

@max

Indeed, turns our I had a non-black specular, that’s why there was a disparity between dynamic and baked. Making specular absolutely black eliminates the issue!

Any ETA on specular lightmaps? :slight_smile:

1 Like

Nice to have this out of the way.

Regarding ETA for specularity. We generally hate of giving dates, as it limits our abilities for striving for high quality, which requires extra time investment and effort. So this is something we are already working on and will be released as soon as quality and results are satisfying. We are talking weeks/months here, not too many though :wink:

That’s great, looking forward to specularity then, when it’s ready.

1 Like