Jump to content

Unity toolkit exported lightmap not appearing in babylon


dsman
 Share

Recommended Posts

We have been doing lightmaps in unity editor and exporting using unity toolkit for many models. And it was working fine. We have done many scenes this way.

Recently we faced a strange issue for a model/scene. The lightmap exported (along with Babylon model) from unity didn't appear in Babylon. 

The toolkit did process .exr file while exporting and then generated lightmap files in the export/scene/  folder as well. 

If I drag-drop the exported babylon mode in editor.babylonjs.com, it also shows the lightmap image in the LightmapTexture dropdown in the PBR tab for all meshes. But it just doesn't appear visually. I checked the .babylon content the file name correctly appears over there too.

Lightmap was very evident to find. So it's not like I might not be able to see the difference even if its there. In unity it shows fine. 

This is completely baffling.  Could it be related to UV? In that case, it should appear correctly in Unity as well. I tried changing value of LightMapTexture dropdown in PBR tab in the babylon editor. Any other normal texture, if selected in the drop-down, shows up fine. 

@MackeyK24

Link to comment
Share on other sites

On ‎2‎/‎9‎/‎2018 at 10:54 AM, dsman said:

We have been doing lightmaps in unity editor and exporting using unity toolkit for many models. And it was working fine. We have done many scenes this way.

Recently we faced a strange issue for a model/scene. The lightmap exported (along with Babylon model) from unity didn't appear in Babylon. 

The toolkit did process .exr file while exporting and then generated lightmap files in the export/scene/  folder as well. 

If I drag-drop the exported babylon mode in editor.babylonjs.com, it also shows the lightmap image in the LightmapTexture dropdown in the PBR tab for all meshes. But it just doesn't appear visually. I checked the .babylon content the file name correctly appears over there too.

Lightmap was very evident to find. So it's not like I might not be able to see the difference even if its there. In unity it shows fine. 

This is completely baffling.  Could it be related to UV? In that case, it should appear correctly in Unity as well. I tried changing value of LightMapTexture dropdown in PBR tab in the babylon editor. Any other normal texture, if selected in the drop-down, shows up fine. 

@MackeyK24

Yo @dsman If you package up the scene in a Unity Package and send to me I will try to figure out whats going on :)

 

 

Link to comment
Share on other sites

@MackeyK24 to help further, following are the serialized JSON object of the material from the .babylon file. Both for the Babylon model which shows lightmap fine and for the one that doesn't. Both were exported from the toolkit. 

Lightmap error: http://jsoneditoronline.org/?id=39ea8159052d2b72e18abb7cd0e560d3

Lightmap success :  http://jsoneditoronline.org/?id=1abf5a1f559f030cc14acbbe8f4ff404

Link to comment
Share on other sites

On ‎2‎/‎10‎/‎2018 at 9:17 PM, dsman said:

@MackeyK24   Here's the package. https://www.sendspace.com/file/9zb037  

There's FBX model of a bathroom that's imported in the scene. I tried with both, checking the "Generate lightmap UV" in FBX inspector tab and without it. 

Yo @dsman  .. I think your problem has to do with the Lighting Mode changes Unity Added... In Lighting Panel --> Mixed Lighting ---> Lighting Mode: Subtractive 

 

Remember, We don't actually use Lightmaps for ANY kind of actual lighting... We use lightmaps as SHADOW MAPS... If you look at the lightmaps exported you will see they have that yellowish color from all the yellow lights in your scene... That is because the Unity Light mode is Baking Indirect light into your Lightmap texture INTEAD of just the shadows it was before...

 

to get the proper shadow only lightmap images, Set lighting Mode to Subtractive... you will notice the BLANK image with just the grey looking shadows.

 

I think that is it... I am cleaning up your scene a bit (Stuff all over the place and no main camera, no scene controller, CANT USE the default UNITY skybox... its procedueral... have to put your own or DONT use tht procedueral SKYBOX)

Takes a little while to bake all the lights... I will let you know if I come up with anything :)

 

 

Link to comment
Share on other sites

@MackeyK24   I was experimenting with various things and just saw the option of "shadow map factor" option under lightmap baking option in Babylon exporter window. I reduce the default value from 5 to 2 and then I could see the lightmap in Babylon. 

I think it reduces the intensity and reduces the too much of brights where the lights should be. 

Also since you said Babylon only uses lightmap as shadowmap. But If the unity generated lightmap has yellowish shade, I do see yellowish shade in  Babylon as well. 

 

Also, can you tell me what takes so much time in exporting the Babylon file? For me, it took a full 20 min on 7th gen i5 laptop. 99% of the time it's processing the lightmap .exr file. 

Thanks a lot for personally looking into this. You're awesome. And I mean it. This Unity toolkit is much much powerful and better replacement of Babylon editor and its so useful. 

Link to comment
Share on other sites

10 hours ago, dsman said:

@MackeyK24   I was experimenting with various things and just saw the option of "shadow map factor" option under lightmap baking option in Babylon exporter window. I reduce the default value from 5 to 2 and then I could see the lightmap in Babylon. 

I think it reduces the intensity and reduces the too much of brights where the lights should be. 

Also since you said Babylon only uses lightmap as shadowmap. But If the unity generated lightmap has yellowish shade, I do see yellowish shade in  Babylon as well. 

 

Also, can you tell me what takes so much time in exporting the Babylon file? For me, it took a full 20 min on 7th gen i5 laptop. 99% of the time it's processing the lightmap .exr file. 

Thanks a lot for personally looking into this. You're awesome. And I mean it. This Unity toolkit is much much powerful and better replacement of Babylon editor and its so useful. 

 Its RE-EXPORTING the .exr for EACH item that has a shadow map... Many items share the shadow map... they each have coordinates inside the lightmap... I will have to optimize that part to only write to disk the first time, all other will check name first before writing the same lightmap multiple times.

 

Link to comment
Share on other sites

11 hours ago, dsman said:

@MackeyK24   I was experimenting with various things and just saw the option of "shadow map factor" option under lightmap baking option in Babylon exporter window. I reduce the default value from 5 to 2 and then I could see the lightmap in Babylon. 

I think it reduces the intensity and reduces the too much of brights where the lights should be. 

Also since you said Babylon only uses lightmap as shadowmap. But If the unity generated lightmap has yellowish shade, I do see yellowish shade in  Babylon as well. 

 

Also, can you tell me what takes so much time in exporting the Babylon file? For me, it took a full 20 min on 7th gen i5 laptop. 99% of the time it's processing the lightmap .exr file. 

Thanks a lot for personally looking into this. You're awesome. And I mean it. This Unity toolkit is much much powerful and better replacement of Babylon editor and its so useful. 

 

Yo @dsman  can you send me another unity package with the changes you made... I wanna see the various settings you have with al the area baking lights you are using.

Did you get the shadows to work by making the lighting mode subtractive ???

Link to comment
Share on other sites

Yo @dsman I think I found the issue(s) ... Im gonna have to REDO lightmap image encoding... I think that is the problem... Should had to fudge the Shadow map factor and stuff like that... The original lightmap source image unity uses internally is a 128 app (HDR) .exr file... We are losing quite a bit going down to 8 bit (32 bpp) png... and the alpha is screwed up to... I am going to do some HDR image decoding and re-encoding down to a 16 bit png preserving as much of the intended lightmap pixels as possible fort our web game (16 bit png is the best we can do without some heavy plugin or decoding like HDR has to down to LDR).

Anyways... I will fix the lightmap issues ... But I still am having issues with just the scene lighting (without the shadows or lightmaps)... I cant get room to light up like the unity scene... I think is has to do with Unity Pre-Computed Lighting... We dont having anything like that (and I dont know how to get to any pre-computed lighting data using the Unity API... if anybody knows that .. let me know I and I will try to make make babylon lighting match the scenes unity pre-computed lighting)

 

Link to comment
Share on other sites

Yo @dsman ... Yep... its all in the encoding... Instead of trying to encode the Unity Version (by messing with the pixels like the first version of the exporter did)... I simply

find the original source HDR (.exr) file for each lightmap and I use my own HDR to LDR encoding to produced a 8-bit (32bpp) lightmap from the the source 128 app HDR.

Note: I am still working on Illumination Issues ... But the shadows look great... Also note I am using way Differ lightmap baking properties:

Note, these are a Final Bake Test Values with final gather and ambient occlusion

 

5a849c2cda583_ScreenShot2018-02-14at10_29_02AM.thumb.png.e2b9f42d5fdc4a0f512ce8c71017de0c.png

 

Original Unity Game View:

 

5a849c4b43898_ScreenShot2018-02-14at10_22_54AM.thumb.png.813c27b2fcc27788e12cea6a9384d30e.png

 

Check next post for my progress so far :)

 

 

Link to comment
Share on other sites

Really cool! WOuld I date asking if you plan to complete the doc as well?

We have plenty of users for your plugin now and it deserves a complete doc with all the great information you are sharing here

Link to comment
Share on other sites

@MackeyK24    Sorry for replying late. I was traveling so couldn't follow up with the forums here. 

For a lightmap I had generated in Unity, I reduced "shadow map factor" such that it's more darker and shows up fine in Babylon. But somehow one particular surface was fully lit as if it didn't have shadow maps. But in fact, if you look at the lightmap texture image, the shadow map for that surface is there. 

Here's the ceiling surface in unity, with a perfectly baked lightmap. 

Screenshot_3.thumb.png.de87485c9180a3c63f923bb99a76acdb.png

 

 

 

 

 

 

 

 

Here's the lightmap image. The ceiling part in the lightmap image is highlighted with arrow. 

Screenshot_4.thumb.png.834bffe6f35d10a5eabbaa6f910160b3.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Here's how it appeared in Babylon. Rest of the places, it appeared fine as you can see. Except ceiling, which is full white. 

 

Screenshot_5.thumb.png.2dd1c180e35d50f2f806ea2eee6b1c81.png

Link to comment
Share on other sites

As for your sample images of Babylon view, the lightmap (or shadowmap) is more dynamic. For me, it always appears a bit flat.   There's something about probably how you are changing some properties/values that affects lightmap/shadowmap's dynamism in Babylon or you updated your code that reads unity's exr and generates higher quality png with higher dynamic range. 

Can you also send a screenshot of your lightmap settings for your Babylon view screenshot you sent above in your last post? I never got that good lightmap. Maybe because I am using progressive lightmapper instead of enlighten+finalgather. But progressive is supposed to be better and realistic. Or did you add any other lights than the ones that were already there in my scene?

 

 

Link to comment
Share on other sites

Yo @dsman  ... I am using My Personal Version Of Babylon Toolkit... I re-wrote the Lighting, Lightmaps (Uses a new direct HDR to LDR of the source lightmap .exr in hdr )... I had to also redo PBR Materials and create a Gloss Mapping System... So yeah my scenes are using way new code with much better quality.... Although I still get issues with lighting the ceiling... How is that ceiling setup... where is the light coming from... my ceiling shows up totally dark for some reason... rest of scene fine ... but is does not like something in the material setup for the ceiling... at least in my personal version of the toolkit.

 

Link to comment
Share on other sites

Yo @dsman and @r3dwolf

 

And @Deltakosh I still can get that reflection issue figured out... Bounding Box Helped. Especially for Position Support. And now I have it in the toolkit

if anybody need to use Local Cubemap mode.... But still does not help with the Rotation issue... Its gotta be something with HDRCubeTexture. 

Regular Cube Textures show what it actually behind me... just the HDRCubeTextures look rotated :(

For me, I want to specialize in Xbox Web Game Development (with targeted UWP functionality when playing on Windows 10 or Xbox One) to Xbox Live Enable my web games... But still have all the Native Game Features, Like drawing to the full Window Core Size at full 1080p resolution on my Xbox One X... I love the UWP stuff and now its all built in out the box:

5a8ad8f9c8ebe_ScreenShot2018-02-19at4_02_14AM.png.d0ee56db3904a269b06d83c1b8dfccac.png

 

I am still woking on a few things. And I need to close up all my Console Development features. You can now target and real time develop for 

Universal Window Platform. The entire WinRT including Xbox Live Services are all built-In the toolkit. You can code again the entire Xbox Live SDK (UWP)

using either Xbox Creators Live Account or the Full ID@Xbox Account. You can out-the-box all the UWP Game platform stuff GameDVR and all the Xbox Live Stuff GameHubs, leaderboard stats, local multiplayer... etc (Note: ID@Xbox account required for Achievement and Online Multiplayer API authorization)

And I am still working no lighting and now RE-DOING the whole PBR Material Export (Both Metallic and Specular)... Trying to come up with my own "Glossing" and "Reflectivity" scenes that look at close as possible to Unity... Remember we are not converting unity content... We are using our own Babylon Json scene file and trying to scrape of as much metadata as we can to re-create the scene in babylon... Unity as all kinds of Forward Rendering Lighting features that contribute to the Lighting and PBR materials... No matter what unity looks like.. in babylon we problem only have two lights... One For Ambient Light and One Directional Light... There is no way to get ALL THE UNITY forward Rendering and precomputed light results you see in unity from just TWO babylon lights...  Anyways... I am still working on...

But check this HIGH QUALITY SPECULAR PBR OF: Unity Adam Character:

In Unity Game View:

5a8ad781897e4_ScreenShot2018-02-19at3_33_14AM.thumb.png.8e33cb2f794515f69d18633b8bdb82b5.png

 

Babylon .. So Far:

 

5a8ad92d0c1ea_ScreenShot2018-02-19at3_44_51AM.thumb.png.6d2f768f7fa1fa9e397ead4019a69ece.png

 

5a8ad9eb3e763_ScreenShot2018-02-19at4_05_16AM.thumb.png.24c9b1b74080d7f7582f53ff92d4e1a6.png

 

5a8ad9ffddde3_ScreenShot2018-02-19at4_05_47AM.thumb.png.c4348d7dd0bddf8e6ac79eceda6994f2.png

 

 

 

 

 

 

 

Link to comment
Share on other sites

On 2/22/2018 at 3:28 AM, dsman said:

@MackeyK24  I want to try the new export code with improve lightmap png conversion so badly. 

It would be so awesome if you can tell me how I can pull your code. 

As soon as I get a version ready for PR. I will let you know then you can just re-grab the toolkit from GitHub. But I am still working on a few things, I will try to get out as soon as I can. I also gotta re-do (again) the documentation :( because some stuff changed in the little documentation is has now.. Especially the lighting and baking and PBR materials.

But again, as as I can, I will put it out there :) 

Link to comment
Share on other sites

@MackeyK24  In my desperation to get better lightmap, I found a simpler way for it. I didn't know converting .exr would be so easy. I used XnConvert software to convert unity project's exr file to convert to jpg. It not only creates high-quality jpg, it also has the option to add so many effects and control image property. So simply boosting contrast, I am getting a much much better result now. Higher dynamism in lightmap. Unity toolkit's export is compressing lightmap jpg way too much I think, it gets pixelated at many places. I am sure you have fixed that in your working copy though. But for now, this tool is handy for us.  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...