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 canfirtina · Jan 13, 2015 at 09:17 AM · animationtexturecolorcubeoptimisation

How to constantly animate thousands of cubes

First of all, I am quite new to Unity. Actually what I mean by "animation" is pretty simple. I only change the color (or texture coordinate) of a cube over time. To make this simple animation smooth, I interpolate from the current color of the cube to its next color in a time interval (lerp functioanlity of unity). Let's say I have 10 different colors for a cube to be represented in 20 seconds. After 20 seconds, it repeats the same animation. These 20 colors can be unique for each of the cubes. Therefore, I need to remember the colors assigned for that cube. I have written the code for the problem I just mentioned. My approach is to create a game object for each of the cube, set a script for that game object and initialise the array in the script, containing the color values to be represented over time. Then, in each update call, every cube updates its own color. So far so good. However, this approach only works once I have no more than 10000 cubes. I have another data that requires me to create about 80000 cubes in the screen. Once I try to create 80000 game objects, the frame per second drops dramatically, as you might guess. I've heard that I need to create mesh chunks if I will have huge number of objects in the screen. My question starts right here. If creating mesh chunks is the right approach for that problem, how am I going to handle the updating color values of each cube? Is it possible to pass an array to shader, and handle the updating color stuff in shaders for each cube? Or which approach should I try? Following image illustrates how the colored cubes look like. Imagine that there were 80000 cubes here and I want to change the color of each cube constantly. alt text

untitled.png (201.9 kB)
Comment
Add comment · Show 1
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 Scribe · Jan 13, 2015 at 09:40 AM 0
Share

do all of your cubes have the same colour progression just offset by different times ie one goes red -> orange -> blue, and the other goes blue -> red -> orange? If so one idea might be to set up stating colours with 'vertex colours' when you create a voxel mesh, and then you could apply a hue shift over time in a shader, just some theory crafting I guess. Could work well if the colour progression is the same for all cubes!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GameVortex · Jan 13, 2015 at 09:21 AM

The meshchunks approach you are describing is the concept know as Voxels. Search around and read up on it. The Unity Asset Store also have a Voxel plugin that might be useful. The game Minecraft uses the same technique and many have tried to create a similar game in Unity so searching around for Unity Minecraft might also yield some good results. Like this: http://in2gpu.com/2014/07/27/build-minecraft-unity-part-1/

Basically: Your color arrays cannot be stored on individual GameObjects but will have to be saved in a custom class containing all information for all the Cubes/Voxels.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Pixel Color Issue 1 Answer

Set the procedural color texture script to a set pattern? 1 Answer

3D Mesh Deformer in Unity3D 2 Answers

Texture Brightness is darker when Loading from another Scene 0 Answers

texture offset question 2 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