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

Lightmap problem in iPhone

Discussion in 'iOS and tvOS' started by blueshadow1109, Jun 7, 2012.

  1. blueshadow1109

    blueshadow1109

    Joined:
    Jun 22, 2011
    Posts:
    11
    The lightmap shows ok in MAC, but when I try to publish the lightmaped scene to iPhone, the lightmap get no lighter any more.

    I tryed to override the lightmap to truecolor, but it doesn't work.

    Attached picture is the sample of the problem.

    The left picture is the right lightmap ground. The midle picture is the iOS version. And the right is the texture itself.

    Any one knows why ? How to achieve the correct lightmap effect in iOS ?

    $Lightmap_in_Mac_vs_iOS.jpg
    ================================================================
    This problem is solved finally.

    You must use the "Mobile" shader (e.g. Mobile/Diffuse), then the lightmap will shows correctly.
     
    Last edited: Jun 29, 2012
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    I don't see an image....
     
  3. blueshadow1109

    blueshadow1109

    Joined:
    Jun 22, 2011
    Posts:
    11
    Can't you see the image ? I've checked with my friend and he can see it...
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    I can see it now, I couldn't see it yesterday.

    What shader are you using?
     
  5. blueshadow1109

    blueshadow1109

    Joined:
    Jun 22, 2011
    Posts:
    11
    Just very ordionary shader diffuse...
     
  6. EricD

    EricD

    Joined:
    Sep 7, 2011
    Posts:
    128
    Set unity to emulate iphone graphics. That always help to see what will will get on iPhone.

    Are you sure the ground is static?
     
  7. blueshadow1109

    blueshadow1109

    Joined:
    Jun 22, 2011
    Posts:
    11
    EricD
    Yes, the ground is static

    I think the problem is when I hit "build" after set the different platform in build setting, the lightmap effect of the scene become different when the target platform is different.

    But, look at the picture below, the "A1" and "A2" area, the light looks almost the same effect. But the "B1" and "B2" area are so different...

    Anyone knows why?...

    View attachment 35580
     

    Attached Files:

    Last edited: Jun 14, 2012
  8. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    Hi everyone!

    We are working on a project using Unity for two months, no problems so far. But recently we decided to add lightmaps via Beast. Everything went great on WebPlayer, but just when switching to Android we found that all colors looked washed out, dark, very gray. The lights are being taken into account to Beast, yes, but enabling the lightmaps makes all scene go dark. We changed lights intensity, buy we only get to saturate everything to gray.

    As it seems we cannot upload attached images, you can find 2 captures on these links:
    - One with WebPlayer selected:
    http://www.hazlo.es/test/WebPlayer.jpg

    - Another one just after switching to AndroidPlayer (and even re-baking the lightmaps just in case):
    http://www.hazlo.es/test/AndroidPlayer.jpg

    I think we've tried everything with no luck. We also searched through this forums, Unity online documentation, Google, Unity answers... but could only find some similar cases but no solutions!

    We are using non-pro Unity with non-pro Android. No shadows enabled. All lights (2 directional ones and 2 point lights) to "bake only". Gamma color space. OpenGL ES 2.0. 32 bits frame buffer, 16 bits frame buffer, all kind of shaders, from Diffuse to Mobile/*, to Legacy/*... We re-bake the lightmaps upon player change, and made the build and installed it in an Android 4.0.4 device just to make sure, but there's no difference.

    We're really desperate. Could someone just give any clue?

    Thanks a million in advance!
     
    Last edited: Jun 15, 2012
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    use a mobile shader, ie unlit.
     
  10. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    Thank you hippocoder, but we already tried Mobile/Unlit, Mobile/Diffuse, Mobile/... but the textures continue to show pale gray. They change a litttle when using such shaders, but they only get a *slightly* less darker gray. But it's almost the same.
    Then you switch to WebPlayer and everything is so gorgeous without ever touching anything...

    Is someone using lightmaps in iOS or Android? Are they working fine? Is it a bug on Beast vs mobile platforms? Or some additional configuration needs to be made in order for it to work on such platforms?

    Please, any additional help will be *very* appreciated!
     
  11. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    To add more information on the problem, please note that in my case the whole scene is darkened by lightmaps because it is composed of a group of static meshes that is entirely affected by "baked only" lights. If the baked lights only affected mostly to a portion of the scene, only this portion would be darkened, like I think it is happening to blueshadow. But only when switching to mobile target. :confused:
    Our Unity3D version is 3.5.2f2, which at the time of writing this, I think it's the latest.
     
    Last edited: Jun 14, 2012
  12. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    Just you know, it seems that Beast is exporting lightmaps in HDR format, which is fine for non-mobile Unity, but mobile platforms seem not to be reading it ok. I read someone was making his own shader and multiplying x4 the lightmap input to get some similar results, but we have filed a bug report with a really simple project with a light and a plane to show it going.
    Will let you know if there's some news about the issue. By now, we'll try to write our own "lightmap booster" shader too, and make it detect if it's working on mobile platforms or not.
     
  13. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    Hey, sorry to "overpost", but in 30 minutes we got response from QA, which I partly quote to share with you:

    "
    We have been able to reproduce this bug and have sent it for resolution with our developers. We cannot say when the resolution will be publicly available.

    We highly appreciate your contribution. If you have further questions, feel free to contact us.
    "

    So we can expect a fix is on the works. It's really a prompt response from Unity staff. That's what I understand as a great support.

    Hope all mobile Unity users with lighmapping issues can find this thread comforting!
     
  14. blueshadow1109

    blueshadow1109

    Joined:
    Jun 22, 2011
    Posts:
    11
    YES~! FINALLY ~!

    Change the shader to "Mobile/Diffuse", then the lightmap goes correct ~!!!
     
  15. carlostmp

    carlostmp

    Joined:
    Jun 14, 2012
    Posts:
    6
    Hi blueshadow. Are you sure your light(s) are not being calc' realtime now? When we were trying for solutions, recreating the lights we once forgot to set them to "baked only" and then magically everything started to work, but it was because of their realtime contribution and not for the lightmaps layer.
    After all, hopefully the bug can be workarounded by using Mobile/Diffuse on iOS, but definitely not in Android, and we tried to create a new shader from the shipping ones to try to modulate x4 the lightmaps, but to no avail (the result is not the same).

    You can download the really simple sample project that was submitted to Unity staff here: http://www.hazlo.es/test/lightmaps.rar
    Could you please try it and change from web to android (or ios for the fact)? At least in Android, if you switch to "Mobile/Diffuse", you see no difference at all, and that's why Unity recognised the bug and is working on the fix.

    We would be glad you found a workaround with hippocoder's suggestion, but then I'm afraid our paths differ from here, as for Android it's no use :(
     
  16. David Brownz

    David Brownz

    Joined:
    Jun 28, 2012
    Posts:
    4
    Hi blueshadow,
    I was facing with lightmap problem form a long time , i tried many things but not getting success now i will try Shader and will back to you. Thanks for sharing such a great idea.
     
  17. alvaro-em

    alvaro-em

    Joined:
    Feb 23, 2012
    Posts:
    77
    [SOLVED] (for Android)

    It seems that Mobile/Diffuse shader does not let dinamic lights to affect lightmapped surfaces. I solved it by using an standard diffuse shader. I also had to change the render mode of the dinamic light to "Important" to see the effects.

    Hope this help.
     
    Last edited: Mar 7, 2013
  18. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    This is still a problem when using Directional Lightmaps.

    There is no Mobile/Specular shader, and the regular Specular shader processes lightmaps in LDR space on iOS. A Specular (and/or Mobile/SpecBump that works with Lightmaps...current one doesn't) is required for Directional Lightmaps.
     
    Last edited: Mar 6, 2014
  19. cloudsyk3

    cloudsyk3

    Joined:
    Aug 1, 2014
    Posts:
    1
    I encounter this bug, and it seems not work. Does Unity fix this bug?
     
  20. Drimarcus

    Drimarcus

    Joined:
    Sep 9, 2014
    Posts:
    1
    I don't think problem is with shaders. Problem is in color space. If you bake you're lightmap in gamma color space, and open it on IOS it will switch it to linear space cause IOS device doesn't support Gamma CS. By doing that colors gets washed out. If you switch your settings for PC.Mac,Linux standalone to linear color space and then light up your scene and bake light maps, you will get proper results on ur IOS device.

    To check this out, go to projects settings>Player>Other settings and see color space drop menu.

    http://prntscr.com/4l4iap
     
  21. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Mobile lightmaps have limited dynamic range. IIRC, they are a multiplier between 0.0 and 2.0 times the intensity of the source texture, so you'll never get 'strong overbrightening' of dark textures.

    For best results, don't use such dark source textures - keep the unlit textures bright, then reduce the lighting intensity as needed
     
    Deleted User likes this.
  22. Deleted User

    Deleted User

    Guest

    @bluescrn agree with you, good resolution. Or we can write custom shader for lightmap.