Home Technical Talk

Baking Directional Light Maps in Blender? Is that possible?

polycounter lvl 6
Offline / Send Message
AlexandrL polycounter lvl 6
Hi folks

I was trying to make a Directionality Lightmaps (Radiosity Normal Mapping)
Find whis topic, but unfortunately its outdated and all the images are gone :/https://polycount.com/discussion/71538/how-to-directional-lightmaps-with-3dsmax-vray

Currently this is what im doing:
Here's my 3 basis which i use to bake GI by Cycles



I was trying to pass basis througth Normal Map node, or normalize them, cause othervice results are look really wierd and depending on camera position (which should be ignored, but somwhow it affecting the scene) i start to get black areas in the viewport and on the baked maps.

Here how i try to "unpack" the light:
I assume what taking a dot product for all 3 basis, mul with all lightmaps should give me the same result as i will get with baking GI with default 0.0.1 normals on the model. But real results already show something wrong. Notice those black spot im marked. It shouldnt be there. Of course if i try to add normal map with some details it will look terrybly wrong.



What im missing? 

Replies

  • Eric Chadwick
  • Noors
    Offline / Send Message
    Noors greentooth
    I probably hadn't the slightest idea of what i was talking about back then and i don't think i messed with RNM since.
    Id say you need to convert your normal map from tangent to world space before the dot product.
    Thought i'd ask why would you want to deal with that in Blender ?
  • elios
    Offline / Send Message
    elios node
    https://forum.unity.com/threads/baking-directional-lightmaps-with-blender-cycles.397334/

    Here is a similar question with the blender setup shown, I have not tried recreating it myself and I think it is intended to be used in unity, but it might be of some help to you. 
  • AlexandrL
    Offline / Send Message
    AlexandrL polycounter lvl 6
    Noors said:
    I probably hadn't the slightest idea of what i was talking about back then and i don't think i messed with RNM since.
    Id say you need to convert your normal map from tangent to world space before the dot product.
    Hmm. I really struggle with understanding and dealing with tangents, so i just run a series of tests.
    My current test shows what i need opposite: im converting pixel normals from world space to tangent space. So basically if i calculate dot with vec3 of 0.0.1 - lightmaps looks okay*
    Same for textures. I use tangent space normals and pass them directly to dot's (after normalize the maps).

    *"okay" because unfortunately i doesnt have access to source engine (or any other using RNM) so i simply doesnt have any ground truth reference to chech how everything looks at my end.

    Btw many thanks for those color values which you post! It looks like calculating those basis vectors as they described in papers are simply doesnt work and should be done in some different ways.
    I achieve some positive results for simple plain, but adding geometry (walls, cubes, etc) - will not gonna work. With "those" colors putted to normal slot for blender diffuse shader - finally getting me somewhere.
    May i ask where you get those numbers?

    Noors said:
    Thought i'd ask why would you want to deal with that in Blender ?
    Honestly i dont have spare bucks for 3dsmax+vray or Maya (i know maya have built-in Turtle render which bake RNM). 
    If you mean in general, why blender and not lightmass - lightmass are too "static". You cant change lightmaps, cant export them for editing. Literally too many restrictions, while with your own lightmaps you can do a lot of cool tricks. 

    Current results:



  • AlexandrL
    Offline / Send Message
    AlexandrL polycounter lvl 6
    Oh crap. The colors on the https://polycount.com/discussion/71538/how-to-directional-lightmaps-with-3dsmax-vray post, are just remap to 0to1 range. I complitely missed that in description (was too tired and sleepy) and looking at 0.5 value i was immidiately thinking about remapping but i was initially calculating the values wrong somewhere and never get correct (the same results) after remapping  :# so was thinking what approach for this values are complitely different.

    Okay, things more clear now and everything kind of works, but i constantly get noticeable seams (for all basis) depending on UV:

    Not really sure is there some errors at my end, or its okay situation for RNM in general or its a problem with blender and cycles?
    I was trying to rotate islands and see what would happen and, well, for some islands orientations seams will defenitely became a bit less noticeable, but they will not dissapear complitely. 
  • Fairplex
    Hey Alexandr. I am trying to recreate your workflow in blender because I do prefer baking my lightmaps manually and I am used with blender. May I ask you how do you bake your basis and how do you combine them in the dot product (I guess this is the node that needs to be used at the end of the chain?)

    I tried to add the same nodes as you show in the beginning but when I bake my x y z lightmaps it dosn't seem to give me the desired output.

    Any help would be really appreciated.
  • Fairplex
    So I was finally able to bake my directional light maps in Blender. And the result is really good. But I cannot compare with other software so I compared with Blender Cycles and the first thing I notice is that I lose a lot of contrast. I wonder if it is a known limitation of the RNM or if there is something I can improve on my side?

    This is the difference I am talking about. First image is Cycles and below its just Eevee with RNM baked.



    AlexandrL said:
    Oh crap. The colors on the https://polycount.com/discussion/71538/how-to-directional-lightmaps-with-3dsmax-vray post, are just remap to 0to1 range. I complitely missed that in description (was too tired and sleepy) and looking at 0.5 value i was immidiately thinking about remapping but i was initially calculating the values wrong somewhere and never get correct (the same results) after remapping  :# so was thinking what approach for this values are complitely different.

    Okay, things more clear now and everything kind of works, but i constantly get noticeable seams (for all basis) depending on UV:

    Not really sure is there some errors at my end, or its okay situation for RNM in general or its a problem with blender and cycles?
    I was trying to rotate islands and see what would happen and, well, for some islands orientations seams will defenitely became a bit less noticeable, but they will not dissapear complitely. 

    I also noticed that but when combined together, the RNM just looks like a regular Lightmap ( which also tend to have visible seams anyway)


  • Noors
    Offline / Send Message
    Noors greentooth
    Pretty cool. Looks like RNM is less contrasted than ground truth, based on this image from Bakery plugin for Unity (which is the baker we use).
    Now i couldn't tell if you could do something to improve it.

    https://geom.io/bakery/wiki/index.php?title=Manual
  • Fairplex
    Noors said:
    Pretty cool. Looks like RNM is less contrasted than ground truth, based on this image from Bakery plugin for Unity (which is the baker we use).
    Now i couldn't tell if you could do something to improve it.

    Yes I am able to boost the contrast by increasing the strength of both RNM color and normal map. Something like x2 for the colors to increase the gamma and x3 for the normals gives something very similar to ground truth:


  • elios
    Offline / Send Message
    elios node
    Fairplex said:
    Yes I am able to boost the contrast by increasing the strength of both RNM color and normal map. Something like x2 for the colors to increase the gamma and x3 for the normals gives something very similar to ground truth:

    Hey, I am about to dive into rnm lightmap baking in Blender myself and I was wondering how your baking process looks - do you manually bake your lightmaps three times, one for each direction or were you able to automate it so that you don't have to? The setup I have at the moment requires me to do that manually three separate times. 
Sign In or Register to comment.