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 Edge Interface · Oct 14, 2014 at 08:01 PM · texturemeshmaterial

Is it possible to save runtime generated mesh as a texture ?

Hi all,

I have bunch of quads organized in a grid 8x8. Each quad has one material assigned out of few available. I rotate each quad by random angle and combine their meshes in specific order. This results in rectangular mosaic with jagged edges, exactly what I want to have.

But this object with mesh combined in such way is just one of multiple similar objects I want to have in my scene. And by multiple I mean up to few thousands of them. Most of them cannot be manipulated by player until some specific conditions are met and they are just stacked around. So I guess it doesn't make much sense to generate let's say 5k of those objects just to have 4995 of them sit there and eat resources.

If I could somehow save each generated mesh as a texture I could just create 5k of simple quads, merge all those not accessible for player into one big mesh (or a few if I happen to hit 65k vertices limit) and rest would be kept as my jagged mosaic objects.

Next I would generate 5k - [number of interactive objects] of "mosaics", merge them all into an atlas and use that to texture my big mesh. With pooling I have already implemented that would be rather fast and not memory intensive operation. All objects that player can interact with would stay in scene and have their meshes, rest would be just look like them. And if some object should be interactive I would just regenerate my big mesh without that one piece.

I don't know if I'm explaining this properly so the bottom line is: is there any way to save mesh (or maybe I should say it's colors?) to texture? And I mean with code not with some editor tool.

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
0

Answer by robertbu · Oct 14, 2014 at 08:35 PM

You can get the pixels from the screen using either Application.CaptureScreensot() or Texture2D.ReadPixels(). If you have Pro, you can use a RenderTexture to capture what a camera sees.

But I have to question your approach. Given a texture atlas of your possible textures, and a mesh, you can present up to 16,000 quads efficiently. The only thing you save by capturing the pixels is a relatively low number of vertices/triangles.

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 Edge Interface · Oct 14, 2014 at 08:56 PM 0
Share

Hmm, but those methods only work if object is actually displayed on the screen, right? In that case it's not what I'm looking for. I was hoping for sth like getting array of pixel values from mesh so I could literally save it to bmp file for example.

Anyway thanks for answer, those things might come in handy at some point.

avatar image robertbu · Oct 14, 2014 at 09:22 PM 0
Share

Actually RendererTexture does not require the object to be seen. For the others, yes they need to be seen for 1 frame.

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

2 People are following this question.

avatar image avatar image

Related Questions

Material doesn't have a color property '_Color' 4 Answers

How to load and render a sprite in script? 1 Answer

How to apply a texture to a submesh 1 Answer

Apply material to imported mesh 3 Answers

Swapping out materials on a skinned mesh renderer? 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