• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by maximeb-valtech · Sep 07, 2017 at 02:42 PM · texturenormalmap

Detect when a texture should be imported as a normal map

I am trying to build an automated import process for artists to send models with all the textures in a zip file and do some auto-import magic. Is there a way to tell from a texture if it is a normal map in a procedural way? From a human point of view, normal maps are very obvious with their blueish tint, but would there be a way for a computer to come to the same conclusion using simple logic?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FortisVenaliter · Sep 07, 2017 at 06:38 PM

Assuming you're only using the standard normal map format (and not, for example, using Unity to generate them from grayscale), I would evenly sample maybe 100 pixels, convert them from RGB to XYZ, and average them. If they are within a tolerance limit (you would have to play with that to get it right), you could assume it's a normal map. You may get some false positives, but it should generally work.

Another way would be to sample the pixels and check if, when converted, they are roughly unit vectors. A standard RGB image would result in vectors of varying lengths, but a properly formatted normal map would typically pre-normalize before encoding into RGB.

The last way, and the best in my opinion, would be to do it with metadata. You could have the artists include a text file with a specific format in the zip files that tells the importer what each texture applies to, much like the OBJ model format's material files.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image maximeb-valtech · Sep 08, 2017 at 04:06 PM 0
Share

I have been trying to implement your second suggestion but am having difficulties. Following the information on wikipedia I was able to transform RGB into XYZ, but I don't get unit vectors on all pixels. Excluding the black pixels, sometimes I get values far below 1 (132, 125, 222) and values far above 1 (33, 166, 239). I'm thinking those might be edge values, but would like confirmation. The median value is indeed close enough to a unit vector. I also tried to check that B never goes under 128, but in Simplygon generated normal maps, it can sometimes drop below that value. Seems like indeed having some meta data would be best.

avatar image FortisVenaliter maximeb-valtech · Sep 08, 2017 at 06:24 PM 0
Share

Also keep in $$anonymous$$d Unity does not store it in native format. So, with your analysis, are you looking at the source image, or the image after Unity transforms it?

avatar image maximeb-valtech FortisVenaliter · Sep 08, 2017 at 06:51 PM 0
Share

Those are the values when it is in Default import settings.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

91 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

export normal texture at runtime 2 Answers

Export Normal Map from Selected Mesh 0 Answers

Normal map strange shading lines. 0 Answers

Importing and configuring Normal Maps at runtime ? 2 Answers

Bumped Diffuse Issue 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges