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 Julien-Lynge · Dec 02, 2011 at 02:43 AM · shadermeshtriangles

Mesh.colors and Mesh.SetTriangleStrip - what do they do?

This question is a two parter. I am trying to explore all that you can do with meshes, and I've come across two things that I just don't understand.

The first is Mesh.Color. It sets vertex colors - what exactly does that mean? I added a script that sets colors for a mesh, and I see no visual change. I've come across a couple tidbits that mention that certain shaders can use the vertex colors - is there any documentation on how to do this? Bonus points if someone can give me a simple unlit or diffuse shader that applies the color to each vertex so we can see the colors visually.

The second is Mesh.SetTriangleStrip. There is literally no documentation for this. I'm guessing it refers to [this][1]. So how do you define the triangle strip, and how do you define the verts so the triangle strip can use them?

Thanks to anyone that can help me figure these out. If someone can provide information, I'll be sure to pester Unity to get it added to their documentation. I'll also create a blog post so people can find it in a google search. [1]: http://en.wikipedia.org/wiki/Triangle_strip

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

Answer by Eric5h5 · Dec 02, 2011 at 03:22 AM

Vertex colors sets colors for each vertex in a mesh. You need a shader that uses vertex colors to see them. Features that are undocumented means that they aren't officially supported, and can change at any time, which means you're generally better off not using them. So, please don't pester them about it. (Pester them about entries in the documentation that exist, but consist of a single line of cryptic text with no examples. ;) ) Mesh.Optimize() creates triangle strips, so you can probably use that instead.

Comment
Add comment · Show 4 · 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 Julien-Lynge · Dec 02, 2011 at 03:46 AM 0
Share

Thanks @Eric5h5

I did a search for "unity shader that uses vertex colors" and finally came across a shader example that you submitted:

http://www.unifycommunity.com/wiki/index.php?title=VertexColorUnlit#ShaderLab_-_VertexColorUnlit.shader

Hopefully that'll be all I need.

As for the second part, even if triangle strips aren't supported, our need is so great that I'm going to try and implement them, and fall back to other methods later if necessary. We're creating a combined mesh of global scientific data with roughly 2.8 million hexagons / 20 million verts that ends up requiring 280 game objects to be instantiated. This takes us about 15 seconds to read in and create, and requires 200$$anonymous$$ of memory per mesh.

I'll try looking into $$anonymous$$esh.optimize, but I'm guessing that would significantly slow things down. We're creating a regular grid, so it's an ideal case for doing the triangle strip ourselves. If you or anyone else could explain the very basics of defining a triangle strip I can take it from there.

avatar image Eric5h5 · Dec 02, 2011 at 04:27 AM 1
Share

$$anonymous$$ost or all of the particle shaders use vertex colors (that's how different particles can have different colors).

avatar image Bunny83 · Dec 02, 2011 at 01:16 PM 0
Share

Sure, here's how a triangle strip works ;)

triangle strip(Wikipedia)

I'm not sure if and how Unity handles "degenerated strips" since there's no documentation about it and i've never used it in Unity ;)

Strips normally require a continous triangle strip so for each additional triangle you need only one extra index value because it uses the two last indices. Note: in a strip the winding order changes every triangle.

avatar image Bunny83 · Dec 02, 2011 at 01:21 PM 0
Share

Just found a great paper about Unity and Triangle strips:

http://www.scribd.com/doc/55687619/15/Degenerate-Triangles

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to return from shader the indexes of triangles/vertices that was actually rendered? 1 Answer

Show triangles of model ingame 1 Answer

Creating a point cloud engine using shaders/meshes 0 Answers

White artifacting bordering mesh triangles 0 Answers

Ways of modificating mesh triangles 3 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