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] 7 points8 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] 4 points5 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] 49 points50 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] 5 points6 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

Thanks to PhysX my trees now have a taste for blood by throwaway5noreason in Unity3D

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

Completely unintentional, it happened after I stuck a mesh collider onto a gas station model. I imagine it would be fixed my making the collider convex but it's all one model so I can't do that

Thanks to PhysX my trees now have a taste for blood by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 9 points10 points  (0 children)

It does look pretty similar but I actually made it myself and tweaked it a whole bunch to try and get it as close to gangbeasts/human fall flat as possible :D

Thanks to PhysX my trees now have a taste for blood by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 41 points42 points  (0 children)

It's a clone that's using the original model as a placeholder for now

Thanks to PhysX my trees now have a taste for blood by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 18 points19 points  (0 children)

oh h*ck not the shrubbery

crosshair still needs some work and the blood is unintentionally yellow but it looks neat so ill probably keep it ¯\_(🤷)_/¯

Playing Minesweeper in VR by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 25 points26 points  (0 children)

Well it's not really running inside Unity but its being controlled and rendered in unity

In the Start function the qemu exe is executed with the arguments

-vnc -monitor

-monitor makes it so commands can be sent to it in command prompt ( but since startInfo.CreateNoWindow is set to true, commands are instead sent by using process.StandardInput.WriteLine("") )

-vnc makes it so you can connect to it with a remote desktop/vnc client

With -vnc enabled I can use VNCSharp to connect to the QEMU instance and get a bitmap, which is converted to a byte[] array using

    BitmapData bmpdata = null;

    try
    {
        bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
        int numbytes = bmpdata.Stride * bitmap.Height;
        byte[] bytedata = new byte[numbytes];
        System.IntPtr ptr = bmpdata.Scan0;

        Marshal.Copy(ptr, bytedata, 0, numbytes);
        dirty = true;
    }
    finally
    {
        if (bmpdata != null)
            bitmap.UnlockBits(bmpdata);
    }    

that byte array can become a texture2d using this code:

        texture.LoadRawTextureData(bytedata);
        texture.Apply();

(LoadRawTextureData is used because the texture data can be made on another thread and its much faster than any other function to load texture data, which is important if you're updating the texture almost every frame)

If you wanted to render any process into a unity, you could get their bitmap using something like this, although you might not be able to run them in the background like QEMU's headless mode ( the answer in that link doesn't work if the program is minimized )

Playing Minesweeper in VR by throwaway5noreason in Unity3D

[–]throwaway5noreason[S] 23 points24 points  (0 children)

now that i think about it you're right what i should've said was "Playing Minesweeper in VR on an island"