Sign in to follow this  
EGDEric

Ideas for implementing force-field sparkle

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this