• 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 Asse · Jun 14, 2010 at 08:27 AM · shadervertex

Shader: Get "normalized" vertex position

I need to get the normalized positions of the vertices.

In other words, when I have a model that has a size of (2, 4) and I get a vertex with a position of (1, 4) I want to recalculate the position to (0.5, 1).

Is this somehow possible without passing the models size by script?

Comment
Add comment · Show 1
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 Asse · Jun 14, 2010 at 11:42 AM 0
Share

Don't mistake size for scale. I mean the meshes bound size.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jonas-echterhoff · Jun 14, 2010 at 10:49 AM

In 2.6, Unity will always scale models before rendering. So, you will get a position of (4, 16, ?) for your vertex in that case. So, there should never be a need to get the scale in the shader. What are you trying to do?

Unity 3.0 will have native rendering for uniformly scaled meshes, with the inverse scale passed in the .w coordinate of the camera position for shaders which need it.

Comment
Add comment · Show 2 · 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 Asse · Jun 14, 2010 at 11:39 AM 0
Share

I need this for a special effect that is best calculated with normalized positions. Anyway, I'm sure there's no way around passing the models mesh size by script.

avatar image Asse · Jun 14, 2010 at 11:45 AM 0
Share

To be more precise, I want to let plants wobble so the topmost vertices have to be transformed farther than the vertices "on the ground".

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

No one has followed this question yet.

Related Questions

Apply a bumped shader on top of a custom vertex shader 1 Answer

How to move vertices up/down randomly in shader. 1 Answer

Add new vertex attributes for a shader,Create vertex attributes 0 Answers

Vertex Displacement Shader Graph With The Camera Moving Issue 1 Answer

Getting vertex data from lighting function in shaders. 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