Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

U3 lightmapping question

Discussion in 'Editor & General Support' started by Silver, Jun 30, 2010.

  1. Ekzuzy

    Ekzuzy

    Joined:
    May 28, 2008
    Posts:
    34
    Hi. I've encountered another problem when using Unity 3 (this time in build 5 but it also occured in earlier versions).

    In the scene showed in the screens I've placed one directional light which casts soft shadows on all geometry. I've baked dual lightmaps. Now when I change the value of "Shadow Distance" here what happens: first any light from the camera to given distance dissapears, then it shows up, then dissapears again, then shows up again etc. Screen shows what I mean (values of Shadow Distance are written on each screen). Light source is set to auto, geometry is static. I don't change anything only Shadow Distance in lightmap view.

    Sometimes the same problem happens when I just rotate the camera - directly illuminated areas flicker: light appears, disappears, appears again etc. It looks like the difference between screen 53 and 66 except that I don't change shadow distance but rotate the camera.
     

    Attached Files:

  2. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    As usual, we need a bug report with the scene attached to be able to do anything about it :wink:

    I'm guessing this issue might be specific to your graphics card, so please make sure you're sending the bug report from the machine you can reproduce the bug on, so that we get your hardware details. Thanks :D
     
  3. GameLvr

    GameLvr

    Joined:
    Mar 22, 2009
    Posts:
    115
    Hi,

    I'm getting a similar problem that appears to be related to using normal maps and real-time shadows.

    I've got the quality turned up to high, 4 cascades, and have tried different distances, but the flickering is extremely bad. I've tried reducing the bump in the normal map, but the flickering is still happening.

    Any ideas?

    thanks
     
  4. thevossman

    thevossman

    Joined:
    Jan 25, 2010
    Posts:
    6
    Hi everyone,
    I have 2 problems...
    1) As instructed I have been baking my whole scene, removing the lightmaps to a different folder in order to keep them safe from deletion, and then clicking "lock atlas"... I bake the single object and all of the light maps disappear from the scene view. Thank i put the old textures back into the scenes folder. At this point I have the option to manually reassign them by dragging them back into place but is there a better way? is there some way to have unity remember what lightmaps are supposed to be on what...they are numbered... I would prefer not to have to reasign 200 maps when i make a tweek :D

    2) What types of materials can you use to create the emissive light on the light maps. I have been using the self-illum shaders and messing around with the illum value and the lightmap settings and I cant get any light to make it to the lightmaps. Also the ojects with the emissive shaders do not have lightmaps after i bake, is this supposed to be this way?

    Thanks!
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    2) Did you ensure that you imported the current asset bundle?
    Also I'm not fully sure it works without Pro as it does not use lights but indirect lighting
     
  6. thevossman

    thevossman

    Joined:
    Jan 25, 2010
    Posts:
    6
    Im not entirely sure what you mean by asset bundle? Im using the second to latest Unity 3 beta, would that have this asset bundle?
     
  7. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    not sure if it is related, but if there is a -scaled poly object in the scene i see this kind of behavior in forward rendering.
     
  8. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Not sure if this is a bug or my misunderstanding of how things should work.

    I have an iPhone project open in U3 beta 7. I place a point light in the scene and enable soft shadows on it - I just want to use this light to bake lightmaps. I get the warning "Only directional lights can have shadows in forward rendering".

    Now, the trick is, the forward and deferred rendering settings are in the PC/Mac standalone Player settings and have no effect on the iPhone project. So how do I go about baking a lightmap? It seems I have to switch my Build platform to PC/Mac, do my lightmapping, then switch back to iPhone platform.

    Is that the way it's meant to be?
     
  9. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Shadows and Deferred Rendering are not supported for the iPhone so they are turned off when in that Build Platform. We decided it was better to not confuse people with making these features available in the Editor if they're not supported on the device rather them making them available for certain tasks like lightmapping.

    So yeah, if you need to visualize your lightmap bakes it is best to switch Build Platforms, lightmap, and then switch back.
     
  10. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    OK - thanks for that. I don't mind doing whatever needs to be done, I just wanted to make sure I wasn't being stupid and missing some completely obvious option :)
     
  11. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    why not just have a lightmap only option for shadows? seems odd to be switching platforms since lightmaps are supported on all.
     
  12. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    I tend to agree that it would be nice to not have to switch platforms to do this. My project takes about 10 minutes to do the platform switch on the latest high-end iMac. That's a 20 minute round trip to bake a lightmap.

    It's not hurting too much at the moment but it would be a nice thing to see improved in a future version.
     
  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    agreed a non-emulation renderer or a "editor visualization mode" would definitely be welcome
     
  14. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    You don't have to switch platforms to get your shadows to bake properly. The only thing is that you won't see realtime shadows in iphone mode to get the feeling where the shadows should be. But if you just enable the shadows on a light and hit bake, you will see baked shadows regardless of the platform you're under.
     
  15. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    This workflow is not really supported in Unity, but writing a script that reassings all lightmaps from a given folder to the lightmaps array shouldn't take more than 10 minutes :)

    You should use the self-illum materials with the Emission value higher than 0, but make sure the objects they're on are marked as static.

    Also you need Unity Pro for that, since emissive materials (and sky lights, for that matter) require Global Illumination from Beast.
     
  16. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Thanks Robert. I'm still not quite getting it, but I'm hoping there will be some tutorials coming along in the near future.

    I'm finding that if I add a point light to the scene and enable shadows, plus "BakedOnly" Lighmapping mode, then I can't see very convincing shadows (i.e. they are barely visible) in the lightmaps. If I switch the light to "RealtimeOnly" then the shadows look great. Maybe it's a setting thing - I just thought that the lightmap shadows would be exactly like the realtime shadows, only baked into the texture.

    PS - just been playing "PuzzleBloom". I love it! That's a REALLY great little game.
     
  17. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Nevermind - just me missing something. I had to reimport the model because I'd added to it and not regenerated the lightmap UVs, so some of my shadows visible realtime were either missing or messed up in the lightmap.
     
  18. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    I'm glad it all works now.

    And about PuzzleBloom - thanks, man! :)
     
  19. ykk

    ykk

    Joined:
    Dec 8, 2009
    Posts:
    51
    the light option no enough. If got area light will be perfect...
     
  20. ocelot

    ocelot

    Joined:
    Jul 7, 2009
    Posts:
    75
    aw man...then how can I lightmap a mario-style side-scoller with hundreds of objects per scene?
    See attached images. (only one level is lit, as a test area)
    Each section of floor/walls between the beams is a separate prefab of multiple floor/wall pieces. We did this to allow for various situations--holes in floor, different ceiling heights, etc.
    This is just a sample section (2nd image) about less than 1/4 the length of the full scene, and the full scene has areas up to 5 levels high.
    Seems like a scene like this would have a whole hell of a lot more than 254 lightmaps.

    thanks so much
     

    Attached Files:

  21. ocelot

    ocelot

    Joined:
    Jul 7, 2009
    Posts:
    75
    oh, also...why might I be getting striped shadows under these shelves on the right? Now, the shelves/items and ladder, along with most all the other props in the scene are 2D .png's -- is Unity wiggin' out because there are 3 of these near each other in this situation? You can see that the ladder has a nice shadow, and the same exact shelf on the left has a nice shadow...

    also, I don't need real time shadows, so I have lightmapping set to single lightmaps, and the point lights used for lightmapping set to BakedOnly


    thanks again
     

    Attached Files:

    Last edited: Jul 13, 2011