Jump to content

Will Babylon (or the editor) have ability to bake maps (Lightmap, AO map etc. ) anytime soon ?


dsman
 Share

Recommended Posts

In short: It's not easy and maybe not practical. You can bake lightmaps in Blender or other 3d editor.

I tried and experimented with lightmaps, even contributed some lightmap function to combine baked lightmaps and dynamic lights/shadows.
https://www.bitofgold.com/lightmaptest/

But after researching a while I realized that I cannot make lightmap baking fast enough in browser.
I tried to render depth maps from every light source and calculating every lightmap texel for every light in 3d - but I can only do this on CPU.
It would take several hours on a fast machine. (for just a plane!)

And there is a mapping problem, easy to do on a plane but if you have a complex scene with many static objects, just optimally placing lightmap UV -s can be a really intensive probem.
So someone has to invent something to do this with shaders.

It's too much for me so I decided to abadon it.
 

Link to comment
Share on other sites

One other thing comes to my mind but it is the same problem as the cascading shadows.
If there would be more shadow generators per light(one for static objects, updated only when light changes (baked!), one smaller high detail map for dynamic objects, updated every frame)
and, there would be an adding or a smooth transition between maps... that would solve shadowing without lightmaps.

Maybe in the future :)

Link to comment
Share on other sites

Consider me naive here but I am not sure why it would be so processing intensive. Because we aren't talking about ray tracing or multiple light bounce here. 
Babylon can comfortably render lights + shadow in real time at multiple fps. So instead of rendering to screen, we have to render light to a texture based on UVs of given mesh (the algorithm used to render bake maps), right ? 

Archilogic has developed such baking (Now 3d.io , look at their App Creator service). They are using Threejs. And I don't think it takes hours for them too. 

Link to comment
Share on other sites

If you do it with babylon vectors and ray tracing in javascript, it is intensive. :D
Lightmap and AO map, I think it involves ray tracing, distance fields and multiple light bounces. But, maybe not.
I did not say it is not possible in webgl... Just that I gave up. :) But even playcanvas has lightmap baking, if someone understands it, it is surely possible in Babylon:
https://github.com/playcanvas/engine/blob/master/src/scene/lightmapper.js

 

Link to comment
Share on other sites

I understand some part of it (not all) the recipe is:
  - for each light, from the light's viewpoint (with a camera!) render theese maps:
  - UV and normal direction map
  - depth map

and combine theese into a RGBM (rgb with magnitude) maps.

and then some processing of theese maps into textures.


 

Link to comment
Share on other sites

The most intreresting part of it is where they render the UV-light direction map:
https://github.com/playcanvas/engine/blob/master/src/graphics/program-lib/chunks/fullscreenQuad.vert

They just need to know at each lightmap texel, where it is in the direction of the light?
So, it renders XYZ position in UV space.

I've got now an itch do start again... :D

Link to comment
Share on other sites

  • 3 weeks later...

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...