Home Technical Talk

Unity Lightmapping for iOS

polycounter lvl 11
Offline / Send Message
CataFa polycounter lvl 11
Hi,

I'm playing a bit around in Unity and I run across an issue with the lightmaps in one scene. Basically in the scene there are some areas where I have very bright light because I need those areas to overbright. Everything works fine on a PC but when I tested the same scene on a mac as soon as I changed the building setting to ios for iphone the lighting changed. You can see a comparison in this picture.

lightmapissue.jpg

it seems to me like if the lightmap has a different range(0-1) and it doesn't overbright the texture anymore when the project is set for ios.
Has anyone experience the same problem? Does building a unity project for the iphone have any limitation with the lightmaps?

Replies

  • bugo
    Offline / Send Message
    bugo polycounter lvl 17
  • Ged
    Offline / Send Message
    Ged interpolator
    check your texture compression settings, sometimes the compression quite noticeably changes the colours being displayed. Im not sure what else it could be as I havent used the lightmapper much myself.
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    to me that looks like iOS is using LDR lightmaps instead of HDR...? Not sure if that is hard-coded or variable somewhere, but it's a start.
  • CataFa
    Offline / Send Message
    CataFa polycounter lvl 11
    Thanks for the answers guys. I've checked all possible settings in the editor but no luck. My idea is sitll as cman2k suggested as well is that somehow a LDR version of the lightmap is used but I haven't found any info about the HDR not being supported on the iphone/ipad.
  • Noors
    Offline / Send Message
    Noors greentooth
    Sorry i absolutely don't know anything about unity (and iphones), but yeah maybe it's not the same shader version on both plateform. You would propably have better chances on Unity forums, they look pretty active. You don't need an HDR lightmap to achieve an overbrighten effect anyway.
  • keres
    Offline / Send Message
    keres polycounter lvl 12
    Gamma calculations are different between these two platforms, at least typically. You may notice a slight variation.
  • commander_keen
    Offline / Send Message
    commander_keen polycounter lvl 18
    Have you tried recompiling the lighting after moving the project from PC to mac? Also make sure you are copying the entire project to mac every time, not just files in the Assets directory.

    Mac uses OpenGL instead of DirectX so there could be a problem with using PC baked lightmaps on OSX, plus IOS doesnt support deferred lighting so using deferred lightmaps in forward rendering would cause problems.
  • CataFa
    Offline / Send Message
    CataFa polycounter lvl 11
    keres: I'm aware of the difference in gamma between the two platforms but in this case that's not the problem.

    commander_keen: I've already tried recompiling and I copied the entire project to mac. (if the project is set to pc or mac standalone everything works fine as soon as I switch to iphone the lighting changes.)I also tried to create a new simple scene from scratch on the mac but I still get the same result that when a yelloq/orange light illuminates a grey texture(my base diffuse for the rocks in mainly in grey tones) it becomes green like in the screenshot i posted. I know ios doesn't support deferred lighting so I'm doing everything in forward rendering.

    I've been messing around with the shader yesterday and instead of using the ones provided with unity I'm rewriting it implementing a modulation 4x of the lightmap and it seems I'm getting somewhere, strange enough considering that the standard ones should do exactly the same thing. I still don't know why this difference in behavior when the unity project is set to iphone but at least I might be able to find a workaround.
    Thanks again for the help.
  • CataFa
    Offline / Send Message
    CataFa polycounter lvl 11
    Hi,

    I took a step back and I did a few tests with a very simple block from my scene and different lighting setup.
    The first image is with the building settings set to ios and the second one with PC/MAC standalone(I'm posting only the lightmapped version because the others are the same).
    You can see how different the results are (light intensity for the point light is 8, for the directional is 2)
    I've also tested with an unlit shader that supports lightmaps but I still get the same strange behavior that everything turn green when the building settings are on ios. Any idea why?
    I also noticed the behavior in general is a bit different from point light and direction light(no matter what building settings), not a huge difference but I'm not sure why, perhaps there is some explanation on how unity handles those light with specific shaders that I'm missing.

    lighting_test_ios.jpg

    lighting_test_standalone.jpg

    One other question that came up is: once I bake the lightmap it seems I can't get back to the lighting I had before even if I clear the lightmap. My pieces become black and don't react to the lights in the scene how they should. Perhaps unity still expect to have a lightmap there and renders them black, is there a way to go back to dynamic lighthing after I baked a lightmap?
Sign In or Register to comment.