Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

normalMap on android

Discussion in 'Shaders' started by Phantomx, May 30, 2014.

  1. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Hey,
    how does normalmaps work on android?
    If I set my texture with normalmap flag it shows wrong ( left image ), it I set it to texture it looks right ( right image ), but still shows wrong on the model. I tried with my own shaders and also unity's basic shaders like mobile/bumped specular but it looks completely broken. works fine in PC/Mac mode but gets broken as soon as I switch to android.

    Any help with that?
    Thanks

    $normalmap.jpg
     
  2. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Cannot confirm, have worked with normal-maps and Android for months just fine. I'm seeing another difference in the above shots, left one is compressed, right one isn't. Have you tried a number of other normal maps? Maybe this map is a one-off "weird case"..
     
  3. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Yes it does that on every normal maps, also tried different compressions settings to see if this was the problem, but it doesn't look like it.
     
  4. RenOli

    RenOli

    Joined:
    Jan 23, 2013
    Posts:
    102
    Humm.. I think it happened to me once... is it PNG?? Try jpg.. se if it works..
     
  5. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    How are you unpacking the normal map?

    For non-mobile platforms, Unity compresses it swizzled. For mobile platforms, it doesn't do that (because it's more costly to unpack).

    The Unity function UnpackNormals from UnityCG.cginc will handle the normal map unpacking correctly depending on what platform you're building to.
     
  6. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    The files are in .tga format.
    I use the UnpackNormals function in my shader. I also tried the defaults unity shaders and does not work either. I'm wondering if it has something to do with my android SDK? does unity use it for texture compression or something?

    thanks
     
  7. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Ok. I can confirm this. Works fine in Desktop, is broken on mobile (Android/iOS/Blackberry).
    I'm using a default bumped diffuse shader. Tried all the options for texture importer. As soon as you convert it to Normal map, it gets this "pink" color instead of being blueish.
    The only workaround I found is to edit the normal map in photoshop, swap channels so the original Red channel ends up in the Alpha channel, and save it as TGA for example.
    I'm pretty sure that's not the expected behavior, as it didn't work like that before. Also, this channel swapping is something that Unity needs to do internally, and not something we need to take care of.
     
  8. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    I'm glad that I'm not the only one with this issue, however we're making a multiplatform game I cannot have 2 sets of normal maps for every model... Is there a better way to submit a bug other than from the menu in unity? because I never got any response from committing a bug from there...
     
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    I don't think so. I'll submit this bug again, and see if I get any response.
     
  10. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    41
    Most likely this is a known editor bug that we're working on already.

    The corrupt-looking normal maps should work ok on the actual mobile devices. The editor just displays them incorrectly on DX11 mode.
    As a workaround, try disabling DX11 from the PC player settings -> "Use Direct3D 11"

    However, do let us know if this doesn't help or if there are faulty results also on the actual HW.
     
  11. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Yeah, that fixed it!
    I'm glad you're aware of this issue and that it's being fixed.
    I think it would be a good idea to post the known bugs somewhere and also post the workarounds you know of.
    If not on the forums, then at least update the issue tracker to state that you're working on a fix, and that there is a temporary workaround. Might save someone else a few hours figuring out what the hell is going on and submitting a bug that UT still has to analyze.
    Thanks!
     
  12. Robert-Ramsay

    Robert-Ramsay

    Joined:
    Aug 28, 2013
    Posts:
    115
    Yep, PC settings, switch off that DX11 and its good for the build on your mobile device. :)

    Thanks!