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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Importing FBX along with normal and specular maps

Discussion in 'Shaders' started by pr1970, Feb 20, 2015.

  1. pr1970

    pr1970

    Joined:
    Feb 12, 2015
    Posts:
    2
    Hi All

    I have a large scene with 40+ shaders in maya that i`d like to export in to Unity, they have diffuse, normal and specular maps. When I import the fbx in Unity only the diffuse textures are automatically coming across into Unity as materials.
    Any ideas how to automatically bring in the fbx with the textures in the correct shader settings.

    Many Thanks
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    You can use an AssetPostprocessor script for that. Not really related to shaders, but more to import scripting.
     
  3. boubouk50

    boubouk50

    Joined:
    Jul 10, 2014
    Posts:
    15
    How do you link the texture to the material though?
    I can handle the importSettings for NormalMaps or HeightMaps thanks to a tag in the name (_NM or _HM) but then, how do I put them in the materials (there can be several) or how can the material knows or gets the correct normalMap?

    Thanks
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    However you want to do it. In our pipeline, we match the normal and height map based on the name of the diffuse map. On import of a model, we try to find any matching maps like a normal map. The folder to look in for normal maps is hardcoded in the script. We then just adjust the (shared) material on the imported model.
     
  5. boubouk50

    boubouk50

    Joined:
    Jul 10, 2014
    Posts:
    15
    What about several materials with different diffuse textures that use the same normalMap?
    Do you duplicate the normalMap texture for each diffuse to make them match?
    Maybe you don't face this problem, but this is a possibility in my program.
     
  6. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Well, that's really what I mean with however you want to do it. In our pipeline, normal maps are usually not shared. Though there is an option to do a "parent search" in our import script. Practically this is implemented by splitting on underscores. So for a diffuse map that is named brick_fancy_red, it will try these normal map options in this order:
    - brick_fancy_red_normal.png
    - brick_fancy_normal.png
    - brick_normal.png

    But you can make any way you would like to do it and you simply put these rules down in the import script. What these rules are, is a more general discussion.
     
  7. boubouk50

    boubouk50

    Joined:
    Jul 10, 2014
    Posts:
    15
    Ok, got it.
    I can manage to write a specific way to make it work, of course. I just don't want to set up a bunch of constraints for the users. Naming can be really painful. I guess there is no such things that has the link info between textures and material, the same the diffuse is linked to the material.
    I will try to handle it with a generated file during the export from the 3D software. I think this is a better way to proceed as the user doesn't have to handle anything and is not constrained.

    Thanks for the quick answers.
    Regards.