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 /
  • Help Room /
avatar image
0
Question by ravenpilot83 · Nov 14, 2020 at 04:14 AM · compute shaderperlin noisemarching cubes

Why is my compute shader returning values I explicitly avoided?

CONTEXT: I've been working with the Marching Cubes algorithm to do some terrain generation stuff. The end goal is pretty much a clone of Worms 3D, but right now the first thing I need is some terrain to work with.

I'm fairly new to unity, but not a scrub. I've been hacking apart Sebastian Lague's Marching Cubes coding adventure to make it fit my needs (github). The main things I wanted to salvage from his code was his use of compute shaders to generate some nice noise (perlin I think?) and to perform the marching cube algorithm.

Right now, I'm stuck on the first part. I'm trying to get the points and the noise back from my compute shader. However, points I have EXPLICTLY SAID TO NOT RETURN are being returned somehow, and I'm having a bad time.

Here's the code for the compute shader as it stands right now. There's no noise code here in my noise shader because I have been debugging this for HOURS. I've got a ComputeBuffer to store points and their noise values as Vector4's/float4's. "points" is defined inside Density.compute, and it works in SL's code, so idk what's up.

 #pragma kernel Density
 #include "/Includes/Density.compute"
 #include "/Includes/Noise.compute"
 [numthreads(4, 4, 4)] 
 void Density (int3 id : SV_DispatchThreadID) {
     if (id.x >= 6|| id.y >= 6|| id.z >= 6) 
     {
         return;
     }
     int index = indexFromCoord(id.x,id.y,id.z);
     points[index] = float4(id, 0.5);
 }
 
 

Yet through extensive use of Debug.Log(), I'm finding I'm getting really weird points in the mix, like (0.0, 7.0, 23.0, -6.9).

I'm getting the points out of the compute buffer by the following code:

         Vector4[] noiseVectors = new Vector4[pointsBuffer.count];
         pointsBuffer.GetData(noiseVectors);

and then looping through the array to put it all in a dictionary for future modification. That's how I'm ultimately getting it back and getting it out of Debug.Log().

The last places I can think of problems arising are: - Are my buffers being populated by random stuff from like data already in memory? - Am I not being careful enough when pulling the data out of the ComputeBuffer? - - If so, why does it work for some points and not others? - Is my ComputeBuffer not being properly defined (code not shown, but it's near verbatim from SL's github)

I dunno folks. Any chance y'all could help me out?

also my first time posting a question. any feedback?

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

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Surface Nets for Smooth Voxel Terrain 0 Answers

Seamless Terrain on Quad Sphere 0 Answers

DrawProcedural draws nothing although buffers are assigned properly 1 Answer

Perlin noise causing Unity to Freeze; am I doing something wrong? 1 Answer

Efficient Multiplication of array of matrices 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