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
2
Question by Tocs · May 21, 2013 at 07:26 PM · normalsurface shadertangent

What subspace are SurfaceOutput vectors in?

I'm creating an anisotropic metal surface shader for my application. I needed tangent vectors in order to compute it correctly in my Lighting function.

Apparently no one ever needs tangents to compute lighting so they didn't bother to make it an easily accessible vector.

So I created a custom SurfaceOutput struct...

 struct SurfaceOutputTangent
 {
     half3 Albedo;
     half3 Normal;
     half3 Emission;
     half Specular;
     half Gloss;
     half Alpha;
     half3 Tangent; //What space should this be in?
 };  

And I have to grab it from a custom vertex shader too...

 void vert(inout appdata_full i, out Input o)
 {
     half3 tangent_input= normalize(i.tangent.xyz); //Transform to correct space here.
 
     o.tangent_input = tangent_input; //Presumably model space at the moment.
 }

So my question is what subspace should my tangent vector be in to be compatible with Normal, and lightDir and viewDir. World (This would be unfortunate), View, or some other space?

I tried looking around for this information but the documentation just glazes over the fact that subspace matters for lighting.

Not here, here, or here...

What space should I put my tangent in? Bonus points if you point me to the matrix name to get it there.

Comment
Add comment · Show 4
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 Benproductions1 · May 22, 2013 at 12:00 AM 0
Share

This is beyond me and deserves to be answered! Consider this bumped!

avatar image Tocs · May 24, 2013 at 03:23 PM 0
Share

Just eyeballing it and trying different subspaces it seems to be world. But I'd love some confirmation.

avatar image Julien-Lynge · Jun 04, 2013 at 10:15 PM 1
Share

So if I understand this, you want the tangent output from your vertex shader to be compatible with the normal and other vectors inside the surface shader?

Couldn't you just get the normal and tangent vectors into whatever space you want within the vert shader and then pass them along to be used later, rather than relying on whatever the surface shader is doing? Then you can just use the UNITY_$$anonymous$$ATRIX_* matrices to get it into whatever form you want. $$anonymous$$g. $$anonymous$$V or $$anonymous$$VP.

avatar image Tocs · Jun 05, 2013 at 07:04 PM 0
Share

True I could explicitly put them in whatever space I felt like but I was trying to conform to Unity's innards. Which is cleaner and keeps my shader shorter. Also I suspect if I recalculate the normal in my preferred space I may create redundancy in the compiled shader depending on how comprehensive their surface shader compiler is.

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

15 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

Related Questions

Dynamically generated bump map for Surface Shader? 0 Answers

Not interpolating surface shader normals (by purpose) 1 Answer

Problem importing baked normal map from 3ds max 1 Answer

How do you find the tangent from a given normal? 2 Answers

How to not require normals in a surface shader 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