2D Glowing Effects

I’m writing a multiplayer asteroids style game, demo at:

http://www.cokeandcode.com/astroprime

I want to add shield, explosions, lasers and general effects. All of this things should really have that glowing style. Now I’ve seen Cas’ Alien Flux, and that looks increadible. I realise thats done by using OpenGL and some sorta 3d stuff to get the style.

I’d rather stick to pure 2D but I’d like to get some similar effects. Has anyone got any tips on how to get the glowing style graphics and/or examples (with or without source).

Cheers for any feedback, help, heckling

Kev

you may need to use translucency which kills the performance immediately as i discovered. eg. make some bright circle gradient… apart from that or dithering, not much luck when it comes to java2d.

[quote]you may need to use translucency which kills the performance immediately as i discovered. eg. make some bright circle gradient… apart from that or dithering, not much luck when it comes to java2d.
[/quote]
Nah. Since the background is mostly black, you can precalculate the alpha in a paint program like GIMP. This would make it look like we’re seeing “glowing” or partially transparent effects, but in reality we’re not. BTW, GIMP has some nice lighting effects in its filter section. You might want to check them out.

He might be using a color background in the future and its really best to take advantage of translucent images that won’t slow your game down.

System.setProperty(“sun.java2d.translaccel”, “true”);
System.setProperty(“sun.java2d.ddforcevram”, “true”);

This allows you to create translucent effects on the fly. I’d start by adding a ALPHA variable to for each of your effects that can be dynamically changed based on the current effect state.

Then in your drawing do something like:
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, SHIELD_ALPHA));
g.drawImage(shieldImg,x,y,null);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));

then modify SHIELD_ALPHA based upon the glowing effect your after.

You will need at least java1.4.03 or greater to enable accelerated transparancy.

I wasn’t really intending to use a different background really, space is black :slight_smile:

Thanks for the replies so far, I’ll experiment and post back.

Kev

Kevin;
I would like to do something very similar to you, (but I will have a non-black background) for magic effects in my rpg. I think that the alpa/translucent images may work if I keep them small. Please do keep us posted.

P.S. This sparked my interest in things like transition effects which I started a new topic On.

Well ya but you could have planets or stars in the background and you lose nothing with alpha blended images using directdraw (windows anyway).

Kryto the alpha blending works great for magic effects and actually saves you video memory because you have fewer images loaded into memory and it looks a ton better.

Great do you have any examples anywhere ;D

hey Kev, what did you end up doing, and are you going to use anything similar in MiniAd? I am looking to make starship weapons with a little more pizzaz then drawpoint, or drawLine, etc…

I found (during Astroprime) that the only way I could really get the type of effects I was looking for was by using alphaing and combining layers to give that intense “glowing” look.

Essentially, I just had sprites with alpha channels which were blitted over and over each other. In OpenGL this looks and works really really well.

However, for MiniAd since I want to stick to pure Java2D I might be a bit stuck for cool effects. However, I’m aiming full release at Java 1.5 and hence I might get some decent acceleration for alpha.

Kev

cool, thanks and good luck.

Check out this article, it may give you some ideas:
http://java.sun.com/products/jfc/tsc/articles/swing2d/index.html