Jump to content
  • Advertisement
Sign in to follow this  
EGDEric

Ideas for implementing force-field sparkle

This topic is 486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was thinking about how one would go about implementing the special effect for a force-field taking a hit. If you've ever seen Star Trek, you know what I'm talking about. When a ship gets hit by a phaser, the shields light up and sparkle at that location.

 

The solution I thought up would be for the ship to be surrounded by a textured sphere/ovoid. The alpha would be 0, but when the shield takes a hit, the alpha for the vertices around that location would go up a certain amount, and the texture would be an animated one, all bluish and sparkly.

 

Any thoughts? How would you approach this? I'm also curious about how one would implement this in a sprite based game.

Edited by totesmagotes

Share this post


Link to post
Share on other sites
Advertisement

There are a bunch of existing shaders that do variations on that theme.

Here's one of the first results.

Basically it is as you describe.  Create a bubble around the object, and wherever it is 'hit' display the texture, otheriwse alpha it out.

Another tactic if your bubble is spherical is to specify a direction and a precision. If the normals match (use the dot product) set the alpha to maximum opacity. As the normals fall away to your precision value, ramp it down to full transparency. 

So if your precision was 0.8, if the dot product was 1.0 it should be fully visible, 0.9 should be half visible, 0.8 or below should be alpha'd out.  If you want a very tight spot you'd use a high number. If you want a broad area use a lower number.

You'd probably want a third parameter to the maximum opacity.  Whatever the actual result is, multiply by that.  If you want the "fully hit" shield to be 70% visible, multiply the stuff above by your 0.7 parameter.

Edited by frob

Share this post


Link to post
Share on other sites
I'm also curious about how one would implement this in a sprite based game.

2d or 3d world? i assumed you were talking pure 3d.  if you're talking a 2D world with 2D sprites, forget what i said, that's for 3D, not 2D. In 2D the ships would never be big enough for any of this to matter, just alpha blend a big red (or whatever color your shields are) circle over it and get on with life. If the ship has front and rear shields, you can light them individually. But further detail will likely be not sufficiently noticeable to bother implementing.

I removed my original post. no sense giving away tricks from my bag for no reason. 

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

In 3D, you can presumably render the bubble that represents the shield with a vertex shader that knows the impact location, the impact time and the current time: enough to animate correctly any hit effect.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!