Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Error occurs when importing normal maps into Unity

Discussion in 'General Graphics' started by aaeriam, Mar 30, 2016.

  1. aaeriam

    aaeriam

    Joined:
    Sep 17, 2014
    Posts:
    10
    I've been trying to important a normal map I made in Photoshop into unity to use for one of my materials; however, the error keeps coming up..

    "Could not create texture from 'file path' file could not be read."

    The files I'm trying to import are TIFF images 1024 x 1024 resolution. It worked perfectly when I imported my jpg's not so much when I try to TIFF files though. I looked at a couple other threads that had similar problems but couldn't find a definite solution to any of them. Any thoughts, tips, or advice are certainly appreciated!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,476
    tiff files seems to work for me (tried on pc + unity 5.3.4f1)

    sounds like the file is in use, or otherwise broken.. can you attach the file here for testing?
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    What color format is your tiff in? Unity doesn't support all of the different ways tiff can be saved, not entirely sure which ones it complains at either, but I think I've seen it fail to import a few I've tried in the past. 8bit and 16bit per channel RGB works if I remember, 16 bit RGBA might not, and greyscale anything didn't seem to. Not sure if I got the same error as you're getting though, and my memory on which ones failed might be wrong too.
     
  4. aaeriam

    aaeriam

    Joined:
    Sep 17, 2014
    Posts:
    10
    @mgear Not sure if I can upload the tiff here directly but the file works fine in photoshop and opens fine with any typical picture viewer. (any idea where I could share the file to you guys so you can test it out?)

    @bgolus the color format is RGB, haven't tried grayscale or anything else. I've tried saving it as 16 bit once or twice but most of the time I've just been saving it as the default 32bit (picture to show my typical save settings the newest picture is in grayscale because i'm going to try testing it out) Screen Shot 2016-03-30 at 3.30.38 PM.png
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,476
    I just tried the same (in different formats and color spaces), still works fine here..

    you can zip the tiff file then can attach.
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    Yeah, photoshop is showing that as a 32 bit float greyscale image, and that looks like it's a single channel from a normal map. You're trying to save that as a 16 bit, 24 bit, or 32 bit single channel grey image and not an 24 bit RGB or 32 bit RGBA.

    Your normal map should look something like this.


    Note that by default Unity treats textures set to normal map as height maps that you want converted into normal maps, which is quite frustrating since Unity honestly does a crap job at this. You should have an image like above, set the image type to normal map, and check off create from greyscale.
     
  7. aaeriam

    aaeriam

    Joined:
    Sep 17, 2014
    Posts:
    10
    @mgear for whatever reason, an error keeps coming up whenever I try to upload the zip file.

    @bgolus So you're saying I need to save it as 24/32 bit RGBA instead of 32 bit float? Sorry if that comes off as a strange question. I'm used to playing around with the levels of an image to create bump maps and such where I'd normally save the image as a jpg. This is my first dive at trying to create normal maps at all.
     
  8. aaeriam

    aaeriam

    Joined:
    Sep 17, 2014
    Posts:
    10
    Actually I figured out a workaround that let me save it as a jpg instead of a tiff which imported in Unity without any problems. I just opened the diffuse image, went to the "Filter" tab at the top then down to "3D" and then selected "Generate Normal Map". I'll play around with it to make sure it creates them properly but I think this might be a solution. Thanks for the help, I appreciate it!
     
  9. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    For future reference don't use jpg if you can avoid it, especially not for normal maps.

    JPEG is designed for lossy storage of natural images, like photos. It adds artifacts that generally aren't that noticeable for that kind of imagery. For images that are data, like normal maps, you're adding artifacts on top of the ones that DXTC adds (the default PC compressed image format for GPUs) and the compression is much more likely to be noticeable. You're much better off saving to png or tga, both of which add no additional compression artifacts and are fully supported by Unity.
     
    aaeriam likes this.
  10. aaeriam

    aaeriam

    Joined:
    Sep 17, 2014
    Posts:
    10
    Thanks for the advice, I had no idea about that with jpgs. I'll make it a habit to save my maps as png's or tga's from now on!
     
  11. asamatterof

    asamatterof

    Joined:
    Jan 30, 2018
    Posts:
    1
    I had the same issue with a TIFF normal map -- as long as you make your normal map in 72dpi, you can use Quick Export to PNG from the File menu to bypass the TIFF issue with Unity and import it as a PNG.
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    TIFF should be fine, I personally use that format for 16 bpc normals. Just make sure you're using the correct compression option and don't save layers. There are several compression options for TIFF, and half of them are lossless, and the other half are not and will add compression artifacts. There's also no guarantee all of them are equally supported by Unity. The safest bet is no compression or LZW with the layers flattened.

    (It should be noted that LZW compression isn't great and may produce files larger than uncompressed in some cases!)