Search Unity

Normal maps lost in light baking

Discussion in 'Editor & General Support' started by Monops, Feb 21, 2012.

  1. Monops

    Monops

    Joined:
    Jan 12, 2012
    Posts:
    28
    Hello!

    I've done everything: deferred rendering, dual lightmaps and so on, but it does not work.
    I've done a custom surface shader with a custom light model: could that be the problem? Or should I call the normal map in a way the system can find it?

    I don't know, just the lightmaps have no trace of the normal maps and I don't want to lose all the detail.
    Do you know how to fix this?

    Cheers!
     
  2. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,474
    You can have normal maps OR lightmaps. Nasty Unity limit.

    In Unity 3.42 there is a trick to use a point light with realtime only settings to achieve some bump mapping effect. But with that method the bump effect turns out this weak that it makes not really sense to do that. No idea if it works in 3.5. Upgrading to 3.5 triples my drawcall, and so i have to stick with 3.42 for now.
     
  3. Monops

    Monops

    Joined:
    Jan 12, 2012
    Posts:
    28
    Ah, so that's why the support in not answearing to me about that ;) This is a huge limitation.
    So you say I should put some point lights around my bumpy objects to show some bumpiness?

    Cheers!
    Alex
     
  4. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,474
    ...and set them to Realtime in their settings, yes. I have still one point light in the scene to do exactly that. It`s just not really a good option.The effect is weak, but there. But i think to remove it and the normalmaps because of performance reasons anyway. Keep in mind that every light increases the drawcalls. And normalmapped lightmapped geometry reacts not this strong at the realtime lights anyways.

    There are some legacy shaders. The bumped diffuse lightmap shader may be of interest for you. But those shaders are not really good suited to work with the Beast lighting engine. Here the problem is that the lightmap turns out very weak. You have to bake externally too. And you don`t get support and help for that shaders neither. They are legacy.

    All in all it`s a loose loose situation when you want to use lightmaps and normalmaps, unfortunately. No matter which route you go. I hope that Unity will change that with version 4. But i wouldn`t hold my breath for it. You cannot create your game with promises. You have to use what`s available.

    I would say make some tests if the bumpiness that you can reach will suit your needs.
     
  5. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Dual Lightmaps allow realtime lighting in the foreground and thus support normal maps, spec, etc. Also you could use Directional Lightmaps.
     
  6. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,474
    Hmm, when i did some tests back in the time i had no bump effect with Dual Lightmaps neither. Or was this a bug in 3.42, and gots fixed in 3.5? That would be good for 3.5 users, but bad for me, because i cannot use 3.5 at the moment because of the much more drawcalls issue. I hope this gets fixed soon.

    Anyways. I stand corrected, fortunately. Thanks aNTeNNa trEE :)

    Will do some Dual Lightmap tests now ...
     
  7. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,474
    Ah, i knew there was a hook why it didn`t work for me. I`m a Unity Free user. And don`t have Deferred Rendering.

    Quote from the manual:

    Has somebody ever written such a custom shader?
     
  8. Monops

    Monops

    Joined:
    Jan 12, 2012
    Posts:
    28
    Sorry, I tried dual lightmaps as stated in my first post, but no normal maps at all :( I'm using 3.5.
    I'm a Unity Pro user, so no excuse :D
     
  9. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Well, you're also using a custom shader so there are still some variables here. Why not try a Dual Lightmap or Directional Lightmap test bake with a standard bump/spec shader to narrow down whether it's your custom shader or something else.
     
  10. Schlumpfsack

    Schlumpfsack

    Joined:
    May 30, 2010
    Posts:
    607
    it is kinda disappointing that free users are not "allowed" to use normal maps + lightmaps at the same time, because i think normal maps are a standard these days.
     
  11. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    But you can use Dual Lightmapping in forward rendering (free version) with custom shaders as Tiles pointed out.
     
  12. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,474
    And that would mean that you can use Lightmaps and Normalmaps then.

    The problem is i haven`t found such a shader yet. A pity. I think i am not the only one that would be very interested in such a shader :)

    Edit, i think i got it managed to create such a shader that works together with normalmaps at lightmapped geometry by using Strumpys shader editor. It has a default normalmap shader that you can load and modify, and you can add the dual lightmap support by a simple checkbox in the settings, in Settings / Color and Lighting Settings, called Forward Dual Lightmaps. Of course you need to use dual lightmaps then, and check Use in forward rendering when baking.

    I`ve attached the shader too. Import it somewhere in your project, and you should see this shader in the list of available shaders then. Credit goes to Strumpy in this case. Thanks for your tool :)
     
    Last edited by a moderator: Feb 21, 2012
  13. Schlumpfsack

    Schlumpfsack

    Joined:
    May 30, 2010
    Posts:
    607
    will test it tomorrow :)
    thanks to you and Strumpy
     
  14. Monops

    Monops

    Joined:
    Jan 12, 2012
    Posts:
    28
    Ok, I found out I forgot to implemen the "_PrePass" shader: now the normal maps seems to work :D
    But the shadows are now very faint, even at intensity "1": any suggestion?
     
  15. milanbon

    milanbon

    Joined:
    Aug 20, 2011
    Posts:
    1
    Hello.I`ve had similar problem with the normal vs lightmap issue and wanted to check with you guys what do you think about this solution:

    1.Bake light maps as you would usually with one directional light
    2. Duplicate that same directional light after the bake
    3.Set duplicated light to real time only
    4.Tweak duplicated light until satisfied with results

    You might have too bright results at first but I`ve tried different settings after several bakes and it looks perfect with both light maps and normal maps visible as I intended.Of course this only works with static objects,but it`s something :)
     
    Last edited: Aug 19, 2012
  16. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,621
    Well the static are the ones that use light maps.
     
  17. showoff

    showoff

    Joined:
    Apr 28, 2009
    Posts:
    272
    The last time I was able to get light maps and normal maps to work at the sometime I bake out the light maps in a 3d application then I applied the legacy light map normal map shader to my models.
     
  18. danielrugu

    danielrugu

    Joined:
    Jul 24, 2016
    Posts:
    14
    Hi there, 2019 here and wondering if someone has other solutions for version 2018.1? Realtime lights are no option since the frames would go down.

    cave-lighting.jpg
     
  19. EliasCyborn

    EliasCyborn

    Joined:
    Jan 11, 2017
    Posts:
    9
    bump, have the same problem with 2019.1.1f1... how is this even an issue.
    can't post screenshots due to confidential content, but it looks exactly the same, like my norma maps are just removed when baked
     

    Attached Files:

  20. borbs727

    borbs727

    Joined:
    Jan 9, 2018
    Posts:
    2
    I'm having the same problem. The surface just goes totally flat. I can't tell if it's the normals or the roughness or both. I'm using LWRP with shadergraph and this occurs using all the Unity stock shaders as well. upload_2019-12-12_22-34-9.png
     
unityunity