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
1
Question by Asse83 · Jul 18, 2014 at 09:31 AM · 2dmesh

How to create accurate mesh from texture (like 2D sprites)

Unity Pro automatically creates an accurate mesh for 2d sprites that basically fits the non-clear pixels.

Look at this example: http://cdn1.raywenderlich.com/wp-content/uploads/2014/01/sprite_mesh.png

Now Unitys 2d sprites have some overhead for me so I don't want to use them directly. But I really want to know how I can create these accurate meshes. Is there already a script or algorithm out there?

(Please no discussions if I should use 2d sprites directly or not, thanks)

Comment
Add comment · Show 2
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 robertbu · Jul 18, 2014 at 02:12 PM 0
Share

I believe what you are looking at is a polygon collider, not a mesh in the image. For performance, I suggest you do what I always do. Setup a quick sample scene using the shaders you believe you will be using. Drop the FPS script from Unity Wiki in the project. Then write a script that loads the system based on a keystroke or a touch. Then run the app on the target platform. So for example each touch might add 100 (animated?) sprites. See where the FPS drops and after that how quick after it drops does it become unusable as you continue to add. Then if you want to take it a step further, compare that performance with one using Quads ins$$anonymous$$d.

avatar image Asse83 · Jul 21, 2014 at 07:02 AM 0
Share

Nope, I'm looking for creating a mesh that's more accurate than a simple square since checking for alpha is expensive for the GPU and having a more accurate mesh reduces these checks.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mefistofel · Jul 21, 2014 at 08:34 AM

There is a lot of algorithms for finding contour of figure. It can be http://en.wikipedia.org/wiki/Marching_squares with optimisations. Optimisation of contour(like mesh optimisation) - complicated theme. http://research.microsoft.com/pubs/68244/meshopt.pdf If for you it's a one-time solution, it is better to use square meshes or optimize meshes by hands in 3d editor.

Comment
Add comment · 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
1

Answer by Asse83 · Jul 22, 2014 at 08:19 AM

Thanks for the links, very interesting! I'll check them out later.

My current solution is to simply create a Sprite with Sprite.Create() and my texture, create a GameObject, add a SpriteRenderer to it and assign the Sprite. Then you can read the mesh data by calling UnityEditor.Sprites.DataUtility.GetSpriteMesh() and so on. Everything is done in code and I destroy the GameObject after reading the data.

Plain but it works...

Of course you'll need the pro version for this feature.

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 jianxi_liu · May 08, 2019 at 02:32 AM 0
Share

hi,could you provide a detail demo about this resolve, i drop into it,thx

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can you manually set the layer order for triangles inside a mesh? 2 Answers

Is it possible to generate a 2D view of a 3D object at runtime? 0 Answers

Texture type -> Advanced -> Mesh type: how it works? 1 Answer

Detecting 2D Mesh Collision 0 Answers

Cancel out mesh alpha 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