12
\$\begingroup\$

I'm trying to achieve the warp effect that you see in games like Geometry Wars.

Screenshot of Geometry Wars including the warp effect

Can someone help explain what is going on here? I feel like the grid's z axis is manipulated in some way, any way, by the programmer, but is there maybe some known mathematical equation to really get the correct warping effect?

Edit: To be more specific, I mean the warping of the grid. How everything looks pulled towards the negative z axis and then bounces.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Are you referring to the background bending about? As it's Geometry Wars, there's a lot of chaos in the screenshot, which has made me scratch my head for a while to try and tell what you were referring to. \$\endgroup\$
    – Grace Note
    Apr 19, 2011 at 14:51
  • \$\begingroup\$ Yes the background bending about. \$\endgroup\$
    – Joey Green
    Apr 19, 2011 at 15:41

2 Answers 2

11
\$\begingroup\$

A 10-minute implementation of a simple spring system (or so he says on his blog ;) ). The system can handle multiple warps and other things distorting the grid.

Updated to add some minor addition detail:

A few other details. From an interview that used to be hosted on the Bizarre Creations website (that site has now disappeared due to the company closure) there was a question:

Q: One of the most striking new graphical features in the game is the "gravity grid" play area. How did you make this look so cool; does every object in the game really have its own gravity? The grid itself is made up of 60,000 points, each one exerting a small amount of force on its neighbour. The simulation itself sits on the edge of stability which is what causes it to swing about so much when one of the game objects gives it a small push! Only a few types of object affect the grid. As the grid system is rather expensive to calculate, it actually runs on the second core along with the audio system, (the first core being dedicated to gameplay and particles, the third is used to render the audio).

\$\endgroup\$
1
\$\begingroup\$

I don't know if there's a "correct" way to do it, but it's likely just an aesthetically pleasing linear transform applied with a falloff calculated from distance to a point.

So for any element you're working with, you'd:

  • find the distance to the center of the warp (d)
  • calculate 1 - d / the max distance of the effect you'd like (i for intensity)
  • clamp that to [0-1]
  • transform the element by lerp( identity, transform, i )

Iirc, Geometry wars applied that as a distorting warp to some elements, while other elements like particles were just affected by the "force", without being distorted. You could apply the distortion in a vertex shader, assuming you had enough vertices to smoothly sample the effect. Alternatively you could render everything that needs affecting to an offscreen buffer first, and then render the results onto a nicely tessellated quad that you apply the distortion to, before adding all the non distorted elements on top.

As for the transform, scaling will give you the sucking in look. If I remember correctly, there was also some twisting going on, which would just be a little rotation.

You can get fancier and fancier with your calculations of the intensity factor to get wackier looking effects. You could, for instance, calculate the angle (a) that an element is relative to the center, and factor that in. Take cos(a) and you can make radial waves in the effect. What you want to do is set yourself up with the necessary scaffolding code and then go to town experimenting with different combinations of factors.

\$\endgroup\$
2
  • \$\begingroup\$ Cool thanks I'll try this out. Is the algorithm you describe basically a spring effect? \$\endgroup\$
    – Joey Green
    Apr 19, 2011 at 20:01
  • \$\begingroup\$ Nope, I didn't describe how it would vary over time, so not a spring. I just described how to get the distortion shape you're after. Animating it in the GW style would require adding another factor up there, modulating i over time. Try implementing the whole thing and it should become clear to you that you can scale i to relax or intensify your effect. Pass a sine wave through that modulating value, or bounce it like a 1D spring and you'll effectively bounce the whole thing. Again, once you have a harness with a bunch of variables floating around, experimentation will be your friend. \$\endgroup\$ Apr 20, 2011 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .