Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 oliver-jones · May 11, 2016 at 09:26 PM · mesharrayverticesmesh vertices

Multiple Meshes

Hello,

I have a Texture2D with a width of 512, and a height of 424 which gives a resolution of 217,088 pixels.

I need to convert this image into mesh (ignoring the Z-depth) so each pixel is now a vertex. My problem is that the maximum amount of vertices I can have in mesh is around 65,025 which is 152,063 vertices shy of what I need!

So the answer is to have multiple meshes to achieve this, right?

alt text

As you can see, a single mesh won't work as it doesn't produce near enough pixels (or vertices in this case). I've calculated that to convert this image into mesh (in terms of resolution), I need to have 4 Meshes (3.338). So my question is, what is the best way to do this dynamically?

alt text

And with that said, how would I be able to access each vertex in a linear, logical manor (bearing in mind there are multiple meshes) to be able to give it the same colour given from the pixel data from the image? For example, to get pixel data from the image, I would simply do:

 for(int y = 0; y < 424; y++){
 
     for(int x = 0; x < 512; x++){
     
         //GetPixel( x,  y ) from image Texture2D
     }
 }


But this won't work for the Mesh, as I would have an array of Mesh[size 4] . So this is where it gets complicated for me :/

Any advise would be much appreciated. Thanks!

screen-shot-2016-05-11-at-215441.png (110.3 kB)
screen-shot-2016-05-11-at-220810.png (217.7 kB)
Comment
Add comment · Show 3
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 Stankiem · May 11, 2016 at 09:57 PM 0
Share

Sorry not trying to be snarky but this is really hard to follow for some reason. Why do you need to split an image into vertex per pixel meshes? Sounds incredibly inefficient and not a good idea.

avatar image oliver-jones Stankiem · May 11, 2016 at 09:59 PM 0
Share

Hello, thats okay! The end result is that I want to create a 3D image of the Texture2D via $$anonymous$$esh. And I would like complete control over each 'pixel' with an absolute 1:1 ratio. Thanks.

avatar image Cherno · May 11, 2016 at 09:59 PM 0
Share

You are creating multiple mesh chunks. Each chunk has a starting index value for x and y position, depending on the number of chunks that are needed in both x and y direction. When looping through the the xy positions, subtract this starting value from the current x and y value.

Example: Image is 100x100 pixels. Chunks are 10x10 vertices each. That means you pixel (and total vertex) array is [100,100]. Your chunk array is [10,10] since 100/10 is 10. (total size divided by chunk width/height). The chunk at position 1,9 in the chunk array has starting indices of x = 10 and y = 0. The chunk at position 4,7 in the chunk array has starting indices of x = 30 and y = 60. for(int y = 0; y < 100; y++){

      for(int x = 0; x < 100; x++){
          //GetPixel( x - (current Chunk starting index x),  y  - (current Chunk starting index x)) from image Texture2D
      }
  }

How you actually define your chunk array is up to you; a Custom class that holds the two starting values plus a reference to the GameObject or Chunk $$anonymous$$esh is probably advisable.

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

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

Related Questions

Best Way to Link Vertices into Mesh 0 Answers

How to load all vertices form multiple children of a game object in to one big array? 0 Answers

Is it possible to enable Read/Write of a imported Mesh at Runtime? 0 Answers

Remove unnecessary vertices from plane mesh 1 Answer

Changing Y Value in Vertex Array? 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