• 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
1
Question by toothycat · Jun 22, 2011 at 10:28 AM · custom-shader

Custom mesh vertex formats

I am rendering a mesh with custom vertex/pixel shaders; part of the per-vertex calculation I am performing depends only on the vertex data and constants, and therefore I would like to perform this calculation at mesh import time and store the results in the mesh data.

The calculation I am offloading is only a few multiplies / additions, and so I do not want to introduce extra vertex elements to store the intermediate results as the cost of an extra element will eat up most of the savings. A number of the existing vertex components are not currently in use; the normal's w component, and uvs' y and z components. I would therefore like to reuse these. Is there a way of attaching a custom vertex format to a mesh (e.g. one that uses 4-component uvs instead of the default 3-component or 2-component ones)?

(I do realise Unity has to support devices with fixed function pipelines, however we have already chosen to sacrifice fixed function pipeline support; moreover, the vertex structure declarations in the shaderlab docs have 4-component normals etc. so surely there must be some way of feeding the data in?)

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
2
Best Answer

Answer by Bunny83 · Jun 22, 2011 at 12:34 PM

Unfortunately as far as i know you are limited to:

  • 1x position

  • 1x normal

  • 1x tangent

  • 1x color

  • 3x 2d uvs. (The docs just talk about 2 but there are actually 3)

The bottleneck is the Mesh-class

Comment
Add comment · Show 1 · 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 toothycat · Jun 24, 2011 at 09:31 AM 0
Share

$$anonymous$$y, but thanks for confir$$anonymous$$g that.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Better shader effects on terrain - Bumpmapping or Specular? 2 Answers

Which way to write a shader in Unity is the best? 1 Answer

Using 2+ UVmaps for diffuse/gloss/nmap 0 Answers

What, exactly, in a shader, stops batching from happening? 2 Answers

Shader error: Shader program of type 'vp' already exists at line .... 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