Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 blitzen · Dec 05, 2011 at 06:05 AM · anglenormalssmoothingcalculate

Calculating a Second Set of Normals

I have meshes imported from Blender 2.59 into Unity 3.42, with the importer's "Normals" option set to "Calculate" and a sharp smoothing angle in order to maintain a boxy lighting effect with seams preserved for sharp edges of objects like cubes and flat buildings.

However, there is sometimes still a need for an additional set of normals. For example, shaders that expand and shrink the vertices by moving them along their normals would need them all totally smoothed. Using the importer's calculated seam-split set of normals for this makes the faces break apart along the seams and each move off in a separate direction, which is not what you want.

I'm not sure if you can calculate smoothed normals on the fly in a vertex shader. It would need the normals of all the faces sharing that vertex to average them out, and I don't know if vertex shaders can act on more than 1 vertex at a time, nor if it would be practical performance-wise. Is that possible?

If not, my guess would be that you'd need to have 2 pre-calculated sets of normals - one with the sharper smoothing angle for correct lighting and the other with a full 180-degree smoothing angle for correct movement with the vertex shader. (And if the former set split vertices along seams, then you'd also need to make sure the normals match for the coincident vertices in the latter.)

So the question is, how can one calculate an additional set of normals like this, procedurally or not, with a different smoothing angle, and where can one store it to feed it to the rendering pipeline? It would be nice if you could just define something like "float3 normal2:NORMAL2;" in your shader's appdata or declare it in BindChannels{}, but there seems to be only one "normal" channel to bind and one MeshFilter.mesh.normals available on the scripting side. I could imagine a possible hack in which you store it in MeshFilter.mesh.tangents or MeshFilter.mesh.colors (using just the first 3 of the 4 vector components), but then you'd give up their respective functionalities which you might also need. Is there a better way?

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

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Calculating normals manually 0 Answers

Mesh normals: per face or per vertex? 1 Answer

How do you calculate the rotation of a hexagon based on the six Vector3 points 0 Answers

Books or articles about mesh recalculation 0 Answers

Smooth normals in raycast? 1 Answer


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