Hey guys. I was wondering if there is a mathematical formula to produce the famous "wormhole" effect found in many games and movies, such as Marvel vs Capcom 2's vs screen, StarGate, etc. Tried Googling it, but the closest I've come was this https://gamedev.stackexchange.com/questions/27684/how-do-i-create-a-wormhole-effect-in-c-and-directx but I don't think it will be the same thing I'm looking for. I wan't to be able to have it in my game but so far no luck. It should be similar to this:
Wormhole Effect
1 hour ago, Psychopathetica said:I may have to create a Tunnel mesh on 3D Studio Max, warp the hell out of it, load it into my program, and have a camera follow through
You don't have to model it in Max if you don't want. A tunnel is just a tube with the camera inside, a tube is just a series of rings linked together, rings are just trigonometry... Not too complicated to procedurally generate a tube.
Then it looks like the diameter of the rings varies by the distance along the tube, and each tube segment is rotated slightly from the previous. Turn on alpha blending, and add a partially transparent texture.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
maybe check out this tutorial on how it was done old-school and modernise it. i've seen something done with shaders before on shadertoy some maybe search that if you're looking for something already implemented.
Xscreensaver has a version of it. I haven't checked if this is 3D or 2D-fake however.
There's a video of it here. It is simple but might help you in understanding how this is done.
Well I created the wormhole, and it works great on 3D studio max.
Was easy actually. I just made line splines that interconnect to each other in one twisted pretzel loop with smooth curves, changed the thickness to 100, added a camera to follow around it and vwola. Once I successfully load the wormhole tunnel mesh, how can I go about having a camera move inside? I was thinking of using nodes.
A simple "fake" wormhole way which doesnt involve a moving camara could be:
1. have a straight length of tube in front of the camara
2. textures move towards the near end of the tube by using an offset in the pixelshader.
3. To make it look like there are twists and turns in the tube you could bend the far end of the tube left/right/up/down by making changes in the vertexshader similar to doing skeletal animation.
Its not as "real" as actually flying the camera down a real twisting tube, but it might be slightly simpler if all you are doing is a cutscene rather than something that can be controlled by the player.
My guess is your "real" tunnel will probably look better than this "fake" way however.