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 thijser · Mar 16, 2015 at 09:55 AM · shader3dshaderscompute shaderdatastructure

Generate a large data structure using a compute shader

I know that RWTexture2D Result;

 void CSMain (uint3 id : SV_DispatchThreadID)
     {
         Result[id.xy] = float3(1,2,3);
     }

will result in an texture containing the numbers 1,2,3 however I'm now looking for a way to control a compute shader in such a way as to generate either a 3D texture with control over which order my operation occur or a way to fit a data structure in the return value of the compute shader.

For a simplified example let's say that I want to generate either a 2D array of linked lists with each value in the linked list being equal to 1+the next value so

 9-8-7-6 , 11-10-9-8
 8-7-6-5 , 6-5-4-3-2

from the input texture

 6,8
 5,2

or store the same in a 3D texture (the real version will be more complex so we will not be able compute that 5+2=7 but instead have to relly on the fact that 5+1=6 6+1=7)

Any idea how to do this?

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 joelv · Apr 01, 2015 at 06:35 AM

You can dispatch a compute job over the 2D domain (X, Y) that is your source texture and read the texture data for that position. You can then have that compute thread write the values required in sequence to your destination.

If you know your max depth (maximum number of values in the new dimension) that will be written you can easily store this as just a buffer of size width*height*depth and index into it, or you can set up your RenderTexture with volume.

If you don't know the max depth (or your worst case does not fit in memory) and want to go the linked list way, keep in mind that you cannot use pointers so you need to allocate links from a pool of some sort (using atomics) and use indices into this pool as your link pointers.

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

Make triplanar mapped textures stay in place? 1 Answer

Standard Shader not correctly working on Android 0 Answers

Shader on 3D model not seen over 2D sprites 0 Answers

perform action on shader compilation/update 0 Answers

Build a temporal (unshared) data structure inside a compute shader 0 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