dsman Posted February 9, 2018 Share Posted February 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 10, 2018 Share Posted February 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
dsman Posted February 11, 2018 Author Share Posted February 11, 2018 @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. Quote Link to comment Share on other sites More sharing options...
dsman Posted February 11, 2018 Author Share Posted February 11, 2018 @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 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 13, 2018 Share Posted February 13, 2018 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 GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
dsman Posted February 13, 2018 Author Share Posted February 13, 2018 @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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 13, 2018 Share Posted February 13, 2018 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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 13, 2018 Share Posted February 13, 2018 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 ??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 14, 2018 Share Posted February 14, 2018 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) Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 14, 2018 Share Posted February 14, 2018 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 Original Unity Game View: Check next post for my progress so far Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 14, 2018 Share Posted February 14, 2018 Initial View : Plants and towels behind you Its coming along Quote Link to comment Share on other sites More sharing options...
Guest Posted February 15, 2018 Share Posted February 15, 2018 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 Quote Link to comment Share on other sites More sharing options...
dsman Posted February 16, 2018 Author Share Posted February 16, 2018 @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. Here's the lightmap image. The ceiling part in the lightmap image is highlighted with arrow. Here's how it appeared in Babylon. Rest of the places, it appeared fine as you can see. Except ceiling, which is full white. Quote Link to comment Share on other sites More sharing options...
dsman Posted February 16, 2018 Author Share Posted February 16, 2018 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? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 17, 2018 Share Posted February 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
dsman Posted February 19, 2018 Author Share Posted February 19, 2018 @MackeyK24 Is there any way I can pull your code? I would like to try the new version. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 19, 2018 Share Posted February 19, 2018 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: 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: Babylon .. So Far: Quote Link to comment Share on other sites More sharing options...
dsman Posted February 22, 2018 Author Share Posted February 22, 2018 @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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 26, 2018 Share Posted February 26, 2018 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 Quote Link to comment Share on other sites More sharing options...
dsman Posted February 26, 2018 Author Share Posted February 26, 2018 @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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted February 26, 2018 Share Posted February 26, 2018 That is exactly what im doing in code, without the contrast boost. I am converting HDR to LDR so i end up with perfect tone mapped, high quality lightmap images... i default to png for even better pixel precision. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.