# Is this possible with lightmaps? (screenshots)

**URL:** <https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184>\
**Category:** Questions\
**Tags:** lighting\
**Created:** [February 13, 2023, 6:45pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184 "2023-02-13T18:45:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 13, 2023, 6:45pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/1 "2023-02-13T18:45:14Z")

</div>

If I had a 100% static scene with base textures like this…

 ![textures](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/c/0cee71103972f6d9b8749a82983c53fedadf0672.jpeg)

…is it possible to alter the lighting to this degree purely by swapping out lightmaps on UV2?

 ![lightmap1](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/7/674f3728cc022c5245f9f37c6cc9885283a4eff7.jpeg)

 ![lightmap2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/7/275307e50880913740027129ad8fbf59dc7922e1.jpeg)

Before I dive into “how” to do this, I wanted to start with “is this even possible”, thanks!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [February 13, 2023, 11:12pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/2 "2023-02-13T23:12:27Z")

</div>

good question for @PatrickRyan 🙂 @Vinc3r might know as well ?

---

<div class="post-metadata">

**Author:** ![PatrickRyan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/patrickryan/32/3417_2.png) [@PatrickRyan](https://forum.babylonjs.com/u/PatrickRyan)\
**Post date:** [February 13, 2023, 11:53pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/3 "2023-02-13T23:53:41Z")

</div>

@papajuan, if you are baking light onto static objects like this, swapping out the light map texture should get you close. Though lightmaps will need to be balanced with scene lighting as well so that you can ensure your materials look correct. Unless you just bake out your diffuse color textures to be used as unlit materials, which you could also do, you will need to use both scene lighting and light maps. [This is a simple example of lightmaps](https://playground.babylonjs.com/#ULACCM#37) - press the spacebar to see the different modes of lightmap.

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 14, 2023, 7:25pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/4 "2023-02-14T19:25:20Z")

</div>

Thanks for the response @PatrickRyan.

> [@PatrickRyan](#):
>
> lightmaps will need to be balanced with scene lighting as well so that you can ensure your materials look correct

This makes me think I have an incorrect mental model of how lightmaps work i.e. I guess I thought lightmaps _were_ the lighting. Instead, it sounds like the lightmaps simply lighten/darken the underlying diffuse texture, and we still have to cast scene light on the objects to see them? Something like that?

> [@PatrickRyan](#):
>
> [This is a simple example of lightmaps](https://playground.babylonjs.com/#ULACCM#37) - press the spacebar to see the different modes of lightmap.

Could you please comment on the difference in technique between that lightmapping playground you referenced and this playground which seems to be a very different approach? [https://www.babylonjs-playground.com/#8EGGW2#19](https://www.babylonjs-playground.com/#8EGGW2#19)

Thanks so much for the help!

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [February 15, 2023, 9:13am UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/5 "2023-02-15T09:13:53Z")

</div>

I’m very confident that the effect you want is doable.

If you want to do a quick test, [you can start with this playground](https://playground.babylonjs.com/#ADPQFC#9) (PBR materials and first set of lightmaps already handled).  
Then you can easily made a second lightmaps set, (import [the glTF file](https://models.babylonjs.com/CornellBox/cornellBox.glb) into Blender to tweak the scene), and by using a right naming convention, in combination with tools like the [asset manager](https://doc.babylonjs.com/features/featuresDeepDive/importers/assetManager), you should see that’s it’s possible.

But, if you have in mind to develop a fading between the two sets, in place of just an on/off switch, then I hope you know how to write a shader 🤓 (maybe these kind of effects can be done through the [node material editor](https://nme.babylonjs.com/)?)

---

<div class="post-metadata">

**Author:** ![PatrickRyan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/patrickryan/32/3417_2.png) [@PatrickRyan](https://forum.babylonjs.com/u/PatrickRyan)\
**Post date:** [February 16, 2023, 5:58pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/6 "2023-02-16T17:58:01Z")

</div>

There’s really not much difference between the example in my last post and the one you shared. The biggest difference is that the simple lightmap I shader is used a Standard material and the one you shared is using PBRMaterial for most of the meshes, plus a multimaterial for the furniture. In both cases, we have a lightmap applied to the base color/diffuse texture and the whole scene is lit by scene lighting. Let’s break down the scene you shared:

Base color texture:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/2/e2e7143a58a97c02fa10bb595a7f05fc35c921b4.jpeg)

Lightmap texture:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/8/28f8a83302d203358eb9556b854af1095140794c.jpeg)

Base color and lightmap texture with scene lighting:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/a/dae8b87219e31df4db05355e7006a84a5088e42a.jpeg)

The thing to note here is that this scene uses both a hemisphere light for overall light in the scene and the Babylon standard theatre IBL which is adding some directional color to the surfaces. If you were to disable these lights, your mesh would be entirely black as the light map does not do any kind of emissive operation, only modifies the base color returned in the shader. You can test this by changing the metallic and roughness levels on the PBR material to be metallic 1.0 and roughness 0.0.

What you see here is that the metallic and smooth surface is now reflecting the skybox. Before the material was set to metallic 0.0 and roughness 1.0 so that the material added only the most diffused contributions from the IBL.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/2/f2620fd11d4b20ecb1e6af526589737d87dabb65.jpeg)

You can even see reflections in the brightest parts of the floor with direct sunlight hitting it:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/1/91618f5536cedf9863a7e3840582d1e4801e049e.png)

I also agree with @Vinc3r, though that this workflow is aimed more at changing the scene lighting during a “loading moment” where you cut to a loading screen or are not looking at the scene when the lighting is switched. Lightmaps are not set up to display a smooth gradation between two different textures. If you want that kind of transition, you will need to create a custom shader or node material. You can accomplish this by rebuilding the lightmap math into a node material, but we don’t have a specific node called “lightmap” to mimic the functionality.

I hope this helps, but feel free to ping with more questions.

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 16, 2023, 6:29pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/7 "2023-02-16T18:29:03Z")

</div>

@PatrickRyan this is all so helpful! Thank you for dissecting that scene and providing the analysis. I’ll start hacking at the playground that @Vinc3r posted and make sure I’m getting it (I think I am though).

(Also, not at all looking for smooth transitions – just want to do a hard load of lightmaps based on other things elsewhere. But good to know that would be a shader thing if I ever wanted to attempt that.)

Thanks again!

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 22, 2023, 2:19pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/8 "2023-02-22T14:19:57Z")

</div>

Making progress but everything is really dark:

[https://playground.babylonjs.com/#RM91KG#1](https://playground.babylonjs.com/#RM91KG#1)

 ![darkbjs](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/5/e5a65e39c55e5659859368d3175897ff50371926.jpeg)

For reference, this is what I’m shooting for:

 ![lightblender](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/5/6540edba9422e961f1b4d48668cd3bb8ad5e0c2f.jpeg)

I’m going to keep digging into this, but wanted to check back here in case there was something obvious I wasn’t doing correctly. Thanks!

---

<div class="post-metadata">

**Author:** ![samuelgirardin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/samuelgirardin/32/87_2.png) [@samuelgirardin](https://forum.babylonjs.com/u/samuelgirardin)\
**Post date:** [February 22, 2023, 3:38pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/9 "2023-02-22T15:38:18Z")

</div>

Hi,  
on babylon side maybe you can try :  
_mesh.material.lightmapTexture.level = 50 ;_

[https://playground.babylonjs.com/#RM91KG#2](https://playground.babylonjs.com/#RM91KG#2) ,

however the texture you used is really dark.

---

<div class="post-metadata">

**Author:** ![PatrickRyan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/patrickryan/32/3417_2.png) [@PatrickRyan](https://forum.babylonjs.com/u/PatrickRyan)\
**Post date:** [February 22, 2023, 6:28pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/10 "2023-02-22T18:28:44Z")

</div>

@papajuan, I would agree with @samuelgirardin about the lightmap texture being too dark. However, if you just increase the level of the texture, you quickly get clipping on the bright areas of the scene. Instead, you will likely need to take a more balanced approach between your scene light and your lightmap, adding some brightness to both. I [slightly modified your PG](https://playground.babylonjs.com/#RM91KG#3) to increase the brightness and change the direction of the hemisphere light in your scene to brighten everything up. I also brought your lightmap into photoshop and brightened the curve. Here are the results:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/6/965b0d22332497bbd71ac4c0bff961ec356d6b25.jpeg)

The curve adjustment looks pretty severe, but most of your data is in the lower values of the scene, so we really needed to boost it:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/2/52373eaccd2cb33f450481b72ccba54fea2f6a4b.jpeg)

Using a curve adjustment allows us to specifically brighten ranges of the image without clipping. Adding the rest of the luminance to the scene through the hemispheric light gives an overall boost as well. Balancing them together allows you to open the shadows while still having highlight detail and shadow detail in the scene.

This is just a quick and dirty example. There are a lot of things you will want to do to balance the render to your target light bringing in roughness/metallic values into your shader as well as potentially adding a bloom post process and possibly anti-aliasing. But this should point you in the right direction.

Heres the adjusted jpg as well. Rather than host it, I just replaced the lightmap in the scene by loading from file.

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/4/f460feaaa67011bb885a87a2fcf389ff4d61560f.jpeg)

 ![lightmap_brighter](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/4/141494fa64e6ec7f5d79eb19e186f80c516e30be.jpeg)

I hope this helps, but feel free to ping back with more questions.

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [February 23, 2023, 12:57pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/11 "2023-02-23T12:57:19Z")

</div>

What is your setup for Blender baking? I’ve often notice luminosity differences between the camera render, and the result stored in baked textures, so you may have to increase a bit light intensity and bounces.

(not directly related to your issue but for baking, I greatly suggest [Baketool addon](https://blendermarket.com/products/baketool), which helps a lot for the process)

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 23, 2023, 3:03pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/12 "2023-02-23T15:03:15Z")

</div>

@PatrickRyan WOW what a difference! I did wonder about cranking things up in PS but worried I would be compensating for doing something wrong elsewhere in the process. But if this _is_ the process, great to know – I can do that. Thanks so much for the detailed response!

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 23, 2023, 3:11pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/13 "2023-02-23T15:11:14Z")

</div>

@Vinc3r I’ve just been using these Bake settings:

 ![blender settings](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/c/5c50651a9be65dd9c6766f0a56bae796e2774d64.png)

I’ve not fiddled at all w light bounces but will give that a try to see how it affects things. Thanks so much for the Baketool recommendation. I will buy it today! 🙂 I’m far from a Blender expert so let me know if you have any other general recommendations re: baking lightmaps for BJS.

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [February 23, 2023, 4:34pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/14 "2023-02-23T16:34:00Z")

</div>

Using vanilla Blender baking workflow (which is a pain in the a\*\* 😃), try this:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/0/a0c56d61c2c65ccaa3c4d5ee3581c3e3bd52f0eb.png)

Use the combined mode with glossy, transmission & emit only if needed on some objects.

Here in Baketools:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/5/058ed7b1c97505b4355033e483044b6406e08af7.png)

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [February 23, 2023, 4:43pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/15 "2023-02-23T16:43:47Z")

</div>

Also, maybe you can be interested by a functionnality I’ve put in my ReTiCo addon, to activate Material Outputs by labels, which allow to quickly activate materials set up for the baking render:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/d/0dba0b4d14b464977817ff37d22459c86731b5c2.jpeg)

I haven’t updated [the doc](https://github.com/Vinc3r/ReTiCo/wiki) about this, but you can download the [last version here](https://github.com/Vinc3r/ReTiCo/releases).

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 25, 2023, 11:52pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/16 "2023-02-25T23:52:08Z")

</div>

@Vinc3r So, the workflow of that BakeTool is pretty great. However, I’m getting very different results compared to what I was getting doing the manual bake process (I used the settings from your BakeTool screenshot).

Here is my original PG with the regular lightmap: [https://playground.babylonjs.com/#RM91KG#1](https://playground.babylonjs.com/#RM91KG#1)

 ![orglightmap](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/0/b07d436dd68aba8361cfebb0ec85f93c5c350e99.jpeg)

And here is a PG with a lightmap from BakeTool: [https://playground.babylonjs.com/#RM91KG#4](https://playground.babylonjs.com/#RM91KG#4)

 ![baketoollightmap](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/1/21fa74d53edb5a2a74649d61cbe4d96f0a84aba3.jpeg)

Do you know why I’m getting such wildly different results just by doing the baking differently?

(I’m temporarily not applying any of the lighting adjustments suggested by @PatrickRyan and @samuelgirardin just so I can first understand these differences between regular Blender baking and BakeTool baking)

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 26, 2023, 4:29pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/17 "2023-02-26T16:29:03Z")

</div>

@Vinc3r Ok so now I’m really confused. I just did a simpler test from scratch, and now I’m getting really similar results between Blender and BJS (lightmap from BakeTool).

Blender:

 ![blender simple](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/9/b901884066166a06cf46c2953ae1eec2ae658bad.jpeg)

BJS:

 ![bjs simple](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/5/251fb3217a0b3bf42a502c3cb6a553dd9555f42d.jpeg)  
[(PG here)](https://playground.babylonjs.com/#RM91KG#5)

Any ideas why my previous example had such wild variety but this shows remarkable consistency? Is it the more harsh the lighting, the more you have to fiddle with the lightmaps and other settings?

I’ll keep experimenting…

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [February 28, 2023, 1:42pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/18 "2023-02-28T13:42:44Z")

</div>

> [@papajuan](#):
>
> ![orglightmap](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/0/b07d436dd68aba8361cfebb0ec85f93c5c350e99.jpeg)

You’ve got these lightmaps using Diffuse bake type? Or Combined like in your first post?

But yes, I always in my scene tried to stick to my workflow… and also tweak baking parameters using my feelings. These tweaks are scene-dependant (exterior, interior, sunny or cloudy, etc), and sometimes you have to send lightmaps in a 2D graphic editor.

---

<div class="post-metadata">

**Author:** ![papajuan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/papajuan/32/29924_2.png) [@papajuan](https://forum.babylonjs.com/u/papajuan)\
**Post date:** [February 28, 2023, 2:43pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/19 "2023-02-28T14:43:46Z")

</div>

@Vinc3r I think I have a workable version finally. BakeTool was a game-changer, so thanks so much for that suggestion. I also determined that I had my sunlight set too bright in Blender, and when I dialed that down, the sunlight lightmap started to look right.

Here is my [latest, working PG](https://playground.babylonjs.com/#RM91KG#7). These lightmaps are straight out of Blender/BakeTool, and I’m doing only a little BJS light tweaking per the suggestion of @PatrickRyan.

![lm-swap](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/8/38916b225c266893bcec5f33dccee858a7de7b8c.gif)

Thanks everyone for all of the help!! This is exactly what I was hoping to learn.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [February 28, 2023, 2:58pm UTC](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184/20 "2023-02-28T14:58:30Z")

</div>

This is so cool !!! @PatrickRyan I wonder how we could bump this info to our doc ???

[Next page](https://forum.babylonjs.com/t/is-this-possible-with-lightmaps-screenshots/38184.md?page=2)
