-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realtime Editing #7
Comments
If you want to generate a voxel shape in the CPU, you could use // densityGenerator.Generate (pointsBuffer, numPointsPerAxis, boundsSize, worldBounds, centre, offset, pointSpacing); pointsBuffer.SetData(data); ` in MeshGenerator (fixed size = true, bounds size = 30, num points per axis = 30) at line ~200 in UpdateChunkMesh to generate a voxel ball, To be more exact the arraydata is a Vector4 with 4 floats where xyz is the pos and w is the density, I use 15 and -15 as on/off but 1 and -1 also works Code taken from shader (.compute): |
Thanks I will try that when I get home |
Have edited some code and made https://youtu.be/403JCvVUn4A via CPU |
I'm interested also in making the terrain modified at runtime, do we have any information how we can do this? I have tried so far to set the density manually to some points and recompute the mesh but it doesnt affect anything, I'm close to dead end so any information is much appreciated! |
Made this in ~2h, the code is a bit messy and size is limited to 30, but works: https://youtu.be/S_oqkZgjbms will post project on github soon |
I made the most rookie mistake of all when trying to make my own custom density generator, it drove me nuts. Make sure MeshGenerator is using the MarchingCubes shader, not whatever density shader you're using. My brain went full mush trying to figure out what was wrong. |
Did a inf terrain realtime edit, https://youtu.be/_1c_wpa-d50 |
Amazing, do you have this in repository? I'd like to take a peek in your code if thats okay with you. |
Updated it a bit: https://youtu.be/sj0n86d7Hbg Drive Folder: https://drive.google.com/drive/folders/1t28wldbP_nkK5qRB9NOzSZMk7RtrONLK?usp=sharing Build: https://drive.google.com/file/d/1yV5CajOLG-xGRrqDpFYoaDhaRSUqf5RL/view?usp=sharing Source: https://drive.google.com/file/d/1DsDLje8piv0SlN87bSzAmThhJaU-pSMy/view?usp=sharing |
Nice work Vincent, I'm looking to make basically the same thing when I get a spare moment to breath. Your solution is looking awesome! |
@VincentLagerros I am desperately seeking your help! Can you help me out? I have added you on facebook in the hope we can have a chat about what I see? The problem seems to stem whenever I click on a border chunk in a 3x3x3 set of chunks. This bit of code appears to cause the issue :
We check if the Chunk == null, and if it is, we add it to the main holder, which then causes a nullreferenceexception? |
Hi I was wondering if you could shed some light on how to edit single voxels in realtime similar to 7 days to die or minecraft, I have created a voxel engine in the past but could not get marching cubes working and I have no experience with compute shaders. I cannot figure out how to edit the "voxel array" and update the chunk. I believe that the pointsBuffer holds the information I need however I don't know where it is safe to edit it and also what type of "Array" it is. I have tried
float[] voxels = new float[meshGen.pointsBuffer.count]; meshGen.pointsBuffer.GetData(voxels);
however it returns system.single[] and i do not know how to fix this. I tried making a 2d array but i threw a memory exception error. Any help would be greatly appreciated thank you for your time.
The text was updated successfully, but these errors were encountered: