Spaghettification Shader

The Spaghettification Shader is a special vertex transformation shader to simulate the pull in effect when an object passes the event horizon of the black hole.

Configuration

Target

In our case it defines the position of the center of the black hole. This is where all the objects will be pulled towards

Threshold

If the object position is within the threshold all vertices of the object will be set to zero. That's basically the point where the object completely disappears

Pull Radius

In our case it describes where the event horizon of the black hole starts. From this point the object will start to be spaghettified. The nearer the object is towards the center of the black hole, the bigger the spaghettification effect is.

Glow Color

You can define a glow color so when the spaghettification effect kicks in, the part that starts to be spaghettified will begin to glow:

Pull Curve

Instead of the object being just pulled directly into the center you can define a curve strength in x, y and z axis to create different variations of the pull in effect.

You don't always want the same axis to be manipulated since the axis depends on the direction you are being pulled in.

Let's say you are coming from the right ( +Z axis). For a counterclockwise pull curve you need to manipulate the curve in -X direction. But if you now come from the -Z axis you would need to manipulate the curve in +X direction.

To make your life easier there is a SpaghettificationController attached to this asset that will do the calculation for you.

Changing the curve of the Spaghettification Shader:

Since the ShaderGraph does not have an option to use curves the shader uses a gradient to specify the curve by changing the alpha values.

Unfortunately Unity does not support exposing gradients from the shader.

If you would like to completely change the curve style please directly open the Spaghettification shader and play around with the gradient until the curve behavior fits your needs:

Last updated