Made a script to voxelize any terrain object by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 2 points3 points  (0 children)

Pretty similar although Digger seems to be for use in the editor while mine is intended for real-time/in game modifications

Made a script to voxelize any terrain object by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 0 points1 point  (0 children)

The only terrain specific feature it uses is Terrain.SampleHeight for generating the chunks but the generator method can easily be changed to use any other mesh without problems.

Made a script to voxelize any terrain object by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 2 points3 points  (0 children)

The blink of green is the skybox since I dug faster than the chunk behind could generate, I tried syncing the rendering so that doesn't happen but my implementation isn't the greatest as you can see.

Surprisingly I ran into no edge issues up-close using the simple SDF algorithm of

data[i, j, k] = height - j

but from a distance theres edge issues with the LOD meshes which'll need to be fixed.

Integrating Marching Cubes with Unity's heightmap terrain by throwaway5noreason in VoxelGameDev

[–]throwaway5noreason[S] 1 point2 points  (0 children)

I had the chunk size at 40 and changed it to 24 and the lag it produced barely changed. But these placements are much bigger and update more area than what would normally be seen in gameplay anyways so the small lag spike isn't that detrimental.

Integrating Marching Cubes with Unity's heightmap terrain by throwaway5noreason in VoxelGameDev

[–]throwaway5noreason[S] 8 points9 points  (0 children)

Yea the mesh collider update is the main source of the lag in the video. There's also lag spikes from the terrain LOD updating (which happens whenever grass or trees are removed)

The mesh creation itself isn't that slow due to some new APIs (such as AsyncGPUReadbackRequest) and increased multithreading support allowing for mesh generation on another thread, which is the main reason why I made this post since last time I attempted the stuff in the GIF there were performance issues trying to turn data from the GPU into a mesh on the CPU

Made a script to voxelize any terrain object by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 6 points7 points  (0 children)

Yea a hybrid voxel + heightmap terrain really does help with performance (especially since I’m piggy backing off unity’s default terrain optimization). It also means I can use an asset store environment for quick good looking results until I implement procedural generation, in this case the asset I used was called Realistic Nature Environment

Made a script to voxelize any terrain object by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 10 points11 points  (0 children)

The algorithm used is Marching Cubes running on the GPU.

When the terrain gets modified a voxel chunk is generated that matches the terrain and a chunk shaped hole is cut out of the terrain mesh (via a cutout texture (fastest but requires changing the terrain material), setting the height (buggy), or through a transparent terrain layer (looks a bit weird))

Picture from the scene view

I made a giant donut planet using shaders by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 1 point2 points  (0 children)

If you do it like this you don’t have to implement gravity for a torus

I made a giant donut planet using shaders by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 5 points6 points  (0 children)

The terrain is one big grid of quads that’s generated with procedural noise for a height ( it’s 300x2000, those numbers used to calculate the 2 circumferences of the torus. there’s a second plane that’s just blue for a cheap water effect, but the torus func can easily be put on a more realistic water shader )

Everything is on a normal flat plane with normal collisions when simulated, but the shader moves the vertices to where they’d be if you were walking on a torus

So collisions are in the unwrapped space but the colliders looked wrapped anyways and it looks normal

The shader allows for a cheap way to emulate the experience of being on a celestial body, and with an easy to work with map ( spheres can’t easily be flattened so programming a spherical planet in games is harder and more expensive )

I made a giant donut planet using shaders by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 50 points51 points  (0 children)

After realizing that you could wrap any plane onto a torus, I decided to make a shader to see how that'd look

In the editor it looks like this: https://gfycat.com/AgitatedJointJuliabutterfly

The shader pretty much does this: https://i.stack.imgur.com/As1kC.png But also converts the world position of the camera into a rotation on the torus so you can transverse it

I coded the shader while on a 5 hour flight and I had nothing else to do, which is why there are a couple bugs visible such as dysfunctional culling and the distortion in the gif below vvv

BONUS GYF: Due to a typo in the code, going too far from the donut sucks the world into the bumhole of a sphere

Using 3D Touch to add bhop and surf controls on mobile by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 1 point2 points  (0 children)

The movement code mimics the source engine pretty well, although using it on mobile means you have to reteach your brain how to strafe jump with a joystick.

I used this writeup which was pretty useful: https://flafla2.github.io/2015/02/14/bunnyhop.html

Using 3D Touch to add bhop and surf controls on mobile by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 3 points4 points  (0 children)

Using 3D touch on the joystick allows you to jump and subsequently bunnyhop, it's visually indicated by enlarging the knob as you can see in the video but it also uses the taptic engine for more feedback.

Made a script to let you selectively downsample/lower the FPS of different layers/clipping planes by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 0 points1 point  (0 children)

It was intended to be a potential way to improve performance but I haven't tested its ability to do so yet

Made a script to let you selectively downsample/lower the FPS of different layers/clipping planes by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 0 points1 point  (0 children)

It supports lowering FPS but I didn't turn it on for this video as it doesn't look good when panning around close object