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 burtles · Jul 31, 2018 at 04:22 AM · 2drenderingperformancesprites

How to Display Hundreds of Thousands of Sprites?

I can manage and manipulate my entities just fine with custom classes, the only current problem is rendering them. I have multiple large entities made of tiles which can rotate independently of each other, and the tiles need to change constantly. How can I render these sprites? Unity can barely handle 10k sprites, I need 100k minimum.

Comment
Add comment · Show 4
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 Stratosome · Jul 31, 2018 at 05:28 AM 0
Share

Um, I don't really know sadly, but I thought I'd throw out an idea anyway. What if you used a particle system and had a script manipulate the particles ins$$anonymous$$d to kind of act like your entities?

avatar image burtles Stratosome · Aug 01, 2018 at 12:40 AM 0
Share

I've seen that idea before, but I also need $$anonymous$$ip$$anonymous$$aps and to be able to manipulate individual tiles regularly independent of each other which I'm not sure I can do with particle systems. I don't have much experience with them though so I'm not sure.

avatar image AmirSavand · Jul 31, 2018 at 10:11 AM 0
Share

There must be an alternative to what you're about to do.

avatar image burtles AmirSavand · Aug 01, 2018 at 12:17 AM 0
Share

An alternative to rendering 100k sprites? That's what I'm here asking.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by madks13 · Jul 31, 2018 at 09:13 AM

Depends on what you actually use those for.

If it's interactible tiles, with colliders or some other CPU heavy components, you can't in a normal way. Unity forces the scene manipulation to be mono threaded, which severly limits the possibiilities.

You can try looking at Unity ECS which helps manipulation of thousands of objects. But it is in beta stage and not fully ready for production.

If you simply need to display them, as suggested by Stratosome, use particles.

Comment
Add comment · Show 3 · 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 burtles · Aug 01, 2018 at 12:38 AM 0
Share

I only need to display them, the rest of it is a separate problem that I've mostly solved. So for the particle approach, to see if I'm on the right track here. Say I have a 256x256 grid object, I would make a particle system, set the life to infinite, speed to zero, etc. Then I'd emit 65,536 particles, then use GetParticles and loop through them and place them into their respective grid locations, assign each one the appropriate Texture2D, (or would I need to create a sprite with the Texture2D first?) Then I'd use SetParticles to apply it, and until anything changed, I'd have a square made up of tiles?

Then, since the tiles need to be updated regularly and independently of each other, I'd keep references to those particles (Can you do that?) And change the particles Texture2D/Sprite as needed. But how do I apply the changes, would I have to use SetParticles every time a single square changed? If I'm calling SetParticles for 65k particles per entity on screen, how much of a performance impact will that have? Also, what about $$anonymous$$ip$$anonymous$$aps? Will those have to be created and displayed manually?

avatar image madks13 burtles · Aug 01, 2018 at 08:42 AM 0
Share

To be honest, i haven't used that method...yet. But i have seen some videos using it while searching for information. Also, you said they need to change constantly, so i assumed you meant all at once, not separately. I'm not sure particles allow that, unless you are using some very peculiar custom shader or something similar. That said, i think in your case, ECS is the better choice for you. $$anonymous$$eshInstancedRenderer seem to be the perfect fit for what you want. I suggest you take a look at GravityDemo from Unity samples. It does instantiate around 100k cubes and manipulates them one at a time. You can find the informations about it here

avatar image burtles madks13 · Aug 02, 2018 at 04:52 AM 0
Share

I think you're right, that looks like what I need. I've done very little in Unity 3d, but for 2d, I'd use the same methods, but just draw planes and then somehow get my Texture2D's on them? I haven't had a chance to actually go through any of it, but just based on the video of the demo and description of Graphics.Draw$$anonymous$$eshInstanced I'm pretty sure that's the direction I should take it.

avatar image
1

Answer by Arycama · Aug 01, 2018 at 01:05 PM

What are you trying to draw that requires 100,000 sprites?

Drawing a single mesh with 100,000 faces is definitely possible. However, drawing 100,000 meshes with one face each is not. (This is how sprites are rendered) This is not an issue with Unity, this is how graphics cards are designed.

Depending on how many unique textures you need, you can store them all in a texture-atlas or texture-array, and then use a special shader to render a single mesh with 100,000 quads or more.

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 madks13 · Aug 01, 2018 at 01:40 PM 0
Share

Actually Unity's meshes have a limit of 65k vertices, so it's not possible in most cases. Only when using mesh melting can you have some cases in which you can display so many faces. But this has a workaround : using chunks. Divide the 100k faces in manageable chunks.

The reason i haven't suggested this is because it's used for procedural generation mainly and i consider it too complex for the OP's need.

avatar image _dns_ madks13 · Aug 01, 2018 at 02:12 PM 2
Share

There is support for 32bit index and then more than 64k faces per $$anonymous$$esh since 2017.3. Check the documentation for $$anonymous$$esh.indexFormat

avatar image burtles · Aug 02, 2018 at 04:44 AM 0
Share

I'm drawing ships and other objects that are made up of squares. They are destructible, and the player can build/modify them. I'm currently using a texture atlas (because I started with it) then converting it into an array at run time since unity doesn't support atlases in a usable way. I started out using a texture bombing shader, but couldn't find a solution to the problems caused by lack of mipmaps. I'm sure there is a way to do it with tex2Dgrad but I'm not good enough with shaders to figure out how. It also meant I couldn't have any kind of animation or procedurally generated tiles.

avatar image madks13 burtles · Aug 02, 2018 at 09:04 AM 0
Share

Ok, this is more of a procedural generation thing. There are many difficulties in this sector, mainly because of technological limits. The way one would like to do things is too costly in terms of power and storage space, so people have been inventing new ways of ataining procedurally generated worlds. There are also many ways to approach that. You should look at tutorials before actually trying by yourself. Depending on what features your game is supposed to have, the solution might be more or less complex. That is why you should get more information on the different solutions. I don't have links to give you, but it's not that hard to find by using keywords such as procedural generation or infinite worlds or some such.

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

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

Related Questions

2D URP doesn't clear screen after moving object 0 Answers

Eges from other sprites around it 0 Answers

Can Someone Please Tell Why Graphics Do Not Look The Same as Editor When I Build my Game 3 Answers

Render 2 sprites using one GameObject Unity2D 2 Answers

Sudden frame rate drop during rendering 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