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 Tudor · Apr 18, 2014 at 01:43 PM · shadersopenglcompute shaderdirectx 11

3D Cellular Automata on the GPU

Let's say that I'm working on implementing cellular automata (like Conway's Game of Life) on the GPU using compute shaders. (also, using DX11, not openGL, but that's only half-relevant)

My question is more focused on data structures side of things. In particular, in order to do any sort of cellular automata, you need knowledge of your neighbouring cells.

Right now, I have a RWStructuredBuffer in my compute shader, to which (from c# in unity) I upload a list of points (arranged in the shape of a 3D cube). I can access points via the SV_DispatchThreadID index in the CS, and do shenanigans like apply velocities to each point etc. alt text

But is this good practice when you want each cell to be able to know what its neighbours are? Doing index calculations to figure out what 1d index does a 3d-placed neighbour have, seems suboptimal.

Is there any way you could instead cast rays from each point and return its neighbour? That would be awesome because it would eliminate the need for a cubic "Grid" entirely, and save space (no more "empty"/unused points).

Cheers!

PS: I'm not very familiar with 3d textures, but they aren't available in unity free; so I'd like to stay away from them if possible.

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 LiverX! · May 20, 2014 at 03:20 PM

Just create a 3d array. In that case find the neighbours will be easy. Now the problem is how to simulate. There is two ways: 1)You can use only centered position in cell, just like particle is moving by only in integer numbers. Is is easy way. 2)The true hardcore: using floating numbers for coordinates in gridspace! I'am actually trying to do that in 2d space, but it is realy hard to make it stabilized. Idea: in one cell ypu can place maximum 4 particles, so one cell has information about 4 particles (if collision distance 1 and distance between cells also 1), you always know neighbours of each particle, because it is just closest cells (26 cells in 3d and 8 in 2d space)! Awesome! But how can i know their position in gridspace? By rounding. You have coordinates of particles and if you floor thouse coordinates you'll get the cell, where they are. Sadly part of it is their position change. You have first position of particle, then you apply velocity and getting new position and if this position will different to its cell, so you overwriting free place of new cell, and erasing old (NOT DELETING). You can use position by x lower than 0 to set the place of cell empty, new variables in such a big array is too bad. I think that's all what i can say. Dynamic memory in videocard is not possible or it will by toooo slow. If you don't want to use grid, then check particles each by each, there is no other way out. The cool moment is that my second way to make particle system isn't used by anyone, and if you make it you will be the first, because it works based on floating number coordinates, not integer.


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

21 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

Related Questions

A node in a childnode? 1 Answer

Compile Shader Graph to GLSL 0 Answers

How to make grass on a mesh on a m1 mac? 0 Answers

does unity support OpenGLES 3.0 on android 1 Answer

Problem exporting model 3Ds->Unity 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