Search Unity

Using a bumpmap with baked shadows?

Discussion in 'Editor & General Support' started by kork, Jul 27, 2010.

  1. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    We are currently converting a Unity 2.x project to 3.x. We use the builtin bumped diffuse shader to create a bumpmap on our floor tiles. However once we switch to lightmapping, all the bumps disappear (see attached screen shots). Is there a way to have both light mapped shadows + bump maps?
     

    Attached Files:

  2. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    well there's not an inbuilt way to do this in Unity, but perhaps UT will consider using Beasts ability to render out Radiosity Normal Maps which will allow you to do what you're asking. Here's hoping that they do :)

    Disscussed here.

    But, the simple reason behind the bumps dissapearing is because, traditionally, normalmaps require a direction of light in order to shade your diffuse. This direction is usually obtained from a light. When you bake a lightmap, there's no longer any calculations done to determine the direction of incoming light (a contributing factor to why they are more performance friendly)... and often, "direction" becomes infinite if you have baked GI into you lightmaps (that is to say, light is coming in from all directions!)... Lightmaps generally provide you with an absolute color value at a location.

    What you're after is a directional lightmap... you can read about this here.
     
  3. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Wouldn't just taking the specular effect alone work? Leaving the actual lighting, shading etc. to the lightmaps. That would show up the bumps, right?
     
  4. jwilliamsen

    jwilliamsen

    Joined:
    Aug 8, 2010
    Posts:
    56
    Actually, to get the normal maps working with the lightmapping, you need to switch from the Forward rendering engine to the Deferred Rendering engine by going to Edit>Project Settings>Player and then in the Inspector under the Other Settings, switch the pull-down for Rendering Path to Deferred Lighting. This change may necessitate you recalculating your lightmaps.
     
  5. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    We managed to make it work with forward rendering by using the "legacy" bumped diffuse shader. Actually this gives better results than using deferred rendering, as with deferred rendering, all the precalculated lightmaps seem to be ignored within the shadow distance, and you only get realtime shadows in the near distance, which somewhat contradicts the usage of baked shadows (at least in our game). I am not sure if it is supposed to be this way...
     
  6. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Yes, it is supposed to be that way with deferred rendering in Unity. In the foreground you have dynamic lights/shadows mixed with GI lightmaps that then blend into direct lighting lightmaps in the background.
     
  7. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    Well, that is weird then, as the dynamic shadows look a lot worse than the calculated one's. In deferred rendering I can not see that dynamic shadows are mixed with the light maps. I have attached two shots, one in forward and one in deferred mode. All other settings remain the same. As you can see, in forward mode, i get crisp shadows from the lightmaps but also nice realtime shadows. In deferred mode, the shadows from the lightmaps seem to be nonexistent, so I only get blurry flickering realtime shadows. Also the realtime shadows seem to look more blurry in this rendering mode than they do in the forward mode. I cannot imagine it is supposed to work this way, otherwise, deferred mode would be pretty much useless. So I wonder if I am doing something wrong or if there is something not working as it is supposed to.
     

    Attached Files: