Light effects help wanted.

Hia guys.

More questions from the stoopid noob. :wink:

I have been playing around alot with light for the last week. Light beeing so damn important and making things go from dead and booring to alive and kicking I need to learn alot about light effects.

What I have done so far is that I have been using PointLight that comes from one corner of the univers and lights everything. This creates nice shadows ony my asteroid fields. With different collors to the Ambient light it starts to look really nice.

Though I have a few questions about other effects and how to make them.

  1. Light comming from within spheres and cylinders. I would like to create glowing spheres to create blinking lights on stations, ships and other objects. Ive been playing around with this placing PointLight into a sphere and making it transparent but somehow this doesnt work for me. Next step is to do same thing with cylinders to create laser beams. My idea is here to have a very think cylinder and to get it to glow to make more atmosphearic laser shot effects.

Anyone know how to do this (make shapes glow) or have sample code?

  1. Lens flares. To create light sources that represent the star(s) in the system Id like to use glowing objects that create a lens flare. This I have no clue what so ever on how to do. Any advice?

Thanks in advance.
Tex.

I went through this a little while ago- first up - if a light source is as far away as a star you may as well use a DirectionalLight rather than a PointLight- the effect is similar, but it seems to me that it should be less calculation heavy - I have no evidence for this, though, could be completely wrong.

Secondly, it is disappointing to discover that lights you see in games are all smoke and mirrors. Whenever you see any kind of visible light source in a game, what you have is a picture of a light source on an alpha blended texture in front of a light. In OpenGL and as a result in any rendering library built over it, the only things that are visible are polygons. Lights have an effect on visible polygons but are not themselves visible.

If you are looking at distant stars in a space scene it isn’t worth using real light sources for it - especially as you are limited to 8 light sources anyways - just use pictures of stars to create the backdrop. When you see a light with lens flare ( bit of an aside - I know it’s expected, but you only really need lens flare if there is a lens of some sort for it to flare in…) what you have is a series of alpha-blended circles being moved according to the camera’s relationship with the light. There is a tutorial on this here that at one time I intended to convert to Java3D, but was never able to get it working - so I’m a fine one to advise anyone else :slight_smile: - it explains the principles fairly well though, so worth a look.

Thanks for the break down Breakfast.

So I can only have 8 lights? How is that? Is that a Java3D limitation or some other?

I guess that breaks my plan to use lights for lasers and as ship lights… :frowning:

Tex

EDIT: No I did actually mean PointLight… :wink:

So you basically want a “Glow in the Dark” Object for your
{Hand quote} LASER {hand quote} (ala Austen Powers 2)

Anyways, if you look in the java3d tutorial, you can find how to do it in the 6th chapter 6.7.1

Its a small section that basically says you can use a Material object and set the emissiveColor to the color you want to “glow”

Here is the constructor for Material

Material(Color3f ambientColor,
Color3f emissiveColor,
Color3f diffuseColor,
Color3f specularColor,
float shininess)

Basic Receipe for Glow In the Dark

Create an Appearance Object with the material object. Then create your geometry with this apperance object.

Here is the link where you can get the tutorial from
http://java.sun.com/products/java-media/3D/collateral/

Thanks for motivating me to look this one up (I needed to do this anyways for my current project)

I’m not certain about how the 8 lights thing works - someone was saying that it is a maximum on another thread here, but my understanding previous to that was that 8 lights is the most you can have affecting a single polygon. Someone else who knows more than me contradicted that, though, and they are probably right I dont really recall. It derives from OpenGL rather than Java3D, just another of those little restrictions that you need to be aware of.

Although setting the emmissive colour of a shape will make it “glow” in the gameworld (ie it will behave as a light source) it does not have any glow or penumbral effect as far as the viewer is concerned, so it doesn’t look like a light source- for that you need a graphic. This is why lasers in games tend to look a little bit flat - because they are.

Yep, I’d guess the 8 lights thing comes from OpenGL.

A compliant OpenGL driver must support at least eight lights, but may support more. As the eight is the minimum you can rely on, most OpenGL-using software treats it as the limit.

And that is eight lights total across the entire scene, not eight lights as a maximum that can light a single shape?

Hi
As I understand it 8 lights is a per render pass limit. Java 3d does multi pass rendering, and can cope with more than eight lights, but only 8 cna effect any surface drawn in that pass. This means that if you have one cube in you scene, and 9 lights, all effecting that one cube, you will get strange effects (maybe only one light effecting the cube), and 1/2 the frame rate as it draws the scene twice. be carefull when using more than 8 lights in your scene. If you look at most games they use techniques like light maps, and (not sure what it’s called) fake lights, with lense flare (transparent textured poly with emisive light set). They look convinsing when whizing round space if you get it right :). To do it all with real lights you would need a large number of passes and to get the bounds of you lights spot on so no more than 8 effect any one surface.

HTH

Endolf

Thanks - I’ve been trying to get my head round that for a while.

What i would try out for the laser:
making the long thin cylinder from here to the end, giving it an emissive color material, making it also half transparant and putting a bit smog all around the laser.
Yep, that should look good!

Smog?

sorry, i meant fog

Volumetric fog in Java3D, that’d be neat. Is it actually possible/been done? I thought most techniques for this needed per pixel access.

Kev

How about speckle effects as well for the laser? Without speckle it would just be an ordinary light beam.

Good point- I’m hoping all your lasers will move at the speed of light as well… :slight_smile:

I was wrong with fog, i thought it would act like smoke but not at all, it just makes the background disapear in… fog!

Hey endolf, it looks like you have some cool lighting effects in Dark Void (green and red lights on one of the ships wings). Could those be used for phaser beams or are those actual lights?

Hi all!

I am just wondering why my old FireGL 1 card supports 32 Lights.

bienator

Thanks for the help guys… Im doing my best working this out…

I got another question about the number of lights… If I have 8 lights in the background geometry and say 8 lights in the sceengraph it self that should be ok right. The light in the background geo will not affect the polygons in the scene right?

Thanks Tex

Yep, lights in the background node don’t effect “real” scene nodes.

Kev