Dynamic Lighting

I'm programming a game (in its early stages) similar to Escape Velocity, but it has dynamic lighting. Planets, engine glows, weapon fire, etc., can all illuminate ships. It does not use any 3D models (except inasmuch as they're used to create sprites).

I thought you guys might be interested in the way this works.

For each ship, I have 16 sprite images. These ship does not rotate in these images; rather, the light source revolves around the ship, so that in each image the ship is lit from a different direction.

Then a separate ship image is made for each light source. The angle between the ship and the light source is used to select a sprite image, then the brightness and color balance of that image is adjusted based on the color and intensity of the light source.

These images are added together with something very similar to Photoshop's "lighten" layer mode. Then the final image is rotated to the correct angle to display onscreen.

IMO, it looks very nice, though it is quite processor intensive. The final version of the game will probably have some option to ignore all but the brightest light source to ameliorate this somewhat, and I suppose also an option to ignore lighting entirely.

I guess one drawback is that you can't have ships rendered from odd angles or with solar panels, etc., that move around as you turn the ship. I might add something like this, but it would only work if directional lighting was disabled for that particular sprite (though brightness and color balance could still be adjusted).

------------------
Galaxy's Edge has moved! Download v1.1: (url="http://"http://www.negative-loop.com:1338/401")http://www.negative-loop.com:1338/401(/url)

I like it. It sound very nice in description, but a little long-winded.

Perhaps using true 3D models would be easier. OpenGL would be amazingly less processor intensive than what you proposed.

Check out (url="http://"http://homepage.mac.com/farpoint/")homepage.mac.com/farpoint/(/url) for an example. Note, this engine doesn't have real-time lighting implemented yet (better features are...), but it would be much simpler a job. I did not program this (if only I was so l33t), so don't give me credit.

I wouldn't mind seeing some shots of your work.

------------------
Eytee
farpoint@mac.com

Wow.

------------------
Reciting back thier facts and numbers
that don't make you smart
There's much more to intelligence
And thinking for yourself would be a start -Justin Sane

Does anyone know if EV:Nova takes advantage of any hardware acceleration? (i.e. storing graphic information in video ram, or some such thing?)

Not even sure that it is possible or practical, but I'm curious.

Too cool. I guess another side effect is that rotation angles are arbitrary, not constrained to 36 or 64 discrete states.

Question though: could you do layer compositing in OpenGL to save processor time, the way Quartz Extreme does?

-reg

------------------
"Oh crap. I'm going to hell - I put the Bible next to Mein Kampf again."
-Her Holiness, Pope Jenne "Kirby" Hubbs

Quote

Originally posted by Regulus:
**Too cool. I guess another side effect is that rotation angles are arbitrary, not constrained to 36 or 64 discrete states.

Question though: could you do layer compositing in OpenGL to save processor time, the way Quartz Extreme does?

-reg

**

OpenGL can do compositing. Textures stored in your videocards ram have an alpha channel associated with them, and the OpenGL spec has several pre-defined functions which can be used to composite that texture onto your back buffer.

------------------
Eytee
farpoint@mac.com

We considered something like this briefly during the construction of Nova, but Matt effectively demonstrated that it wouldn't be feasible. To have effective dynamic lighting from a variety of angles (that was smooth, not jumpy), we'd need to render, say, 36 angles of lighting for each ship sprite. That infers that Nova would become 36 times larger than it is now, in terms of both memory usage and disk space. Neither option was acceptable, or even doable.

We did choose to go with layers for ship effects, but limited these to animations (no more than 6 frames), weapon glows, engine glows and running lights. We didn't implement ship shielding because we weren't happy with our ability to make that feature look good, although some have filled that void.

Dave @ ATMOS

------------------
forge
(url="http://"http://www.evula.com")EVula(/url)
(url="http://"http://www.sourcecod.com")sourcecod(/url) for hosting that doesn't suck.

Quote

Originally posted by pipeline:
**We considered something like this briefly during the construction of Nova, but Matt effectively demonstrated that it wouldn't be feasible. To have effective dynamic lighting from a variety of angles (that was smooth, not jumpy), we'd need to render, say, 36 angles of lighting for each ship sprite.
**

Well, my engine has smaller files than EV does (tho EV is definitely smoother on a slow machine); I don't have separate shots of each ship from each direction, just different lighting conditions. The game engine rotates the sprites to the correct angle.

I'll post here again when there's a demo ready to play.

------------------
Galaxy's Edge has moved! Download v1.1: (url="http://"http://www.negative-loop.com:1338/401")http://www.negative-loop.com:1338/401(/url)

(This message has been edited by Giule (edited 08-19-2002).)

Aha! I see, it's a totally different design philosophy. Cool, cool!

Dave

------------------
forge
(url="http://"http://www.evula.com")EVula(/url)
(url="http://"http://www.sourcecod.com")sourcecod(/url) for hosting that doesn't suck.

Quote

Originally posted by Giule:
**Well, my engine has smaller files than EV does (tho EV is definitely smoother on a slow machine); I don't have separate shots of each ship from each direction, just different lighting conditions. The game engine rotates the sprites to the correct angle.

I'll post here again when there's a demo ready to play.

**

Ah. I see. Then you could theoretically make file size smaller than Nova...very interesting.

------------------
Eytee
farpoint@mac.com

Quote

Originally posted by Eytee:
**Ah. I see. Then you could theoretically make file size smaller than Nova...very interesting.
**

Yup, and if I read this right the sprite will always look excellent and smooth from any angle. However, it does limit the view angle to straight on top of the ship, unlike Nova.

I suspect, though, that the scaling, rotation and transparency/colour-shifting in realtime will exact a serious penalty from the processor.

Dave

------------------
forge
(url="http://"http://www.evula.com")EVula(/url)
(url="http://"http://www.sourcecod.com")sourcecod(/url) for hosting that doesn't suck.

Quote

Originally posted by pipeline:
**Yup, and if I read this right the sprite will always look excellent and smooth from any angle. However, it does limit the view angle to straight on top of the ship, unlike Nova.

I suspect, though, that the scaling, rotation and transparency/colour-shifting in realtime will exact a serious penalty from the processor.

Dave

**

But couldn't Quartz/Quartz Extreme be used here to increase performance? Seems like Apple created an entire graphics library just to allow such processor intensive image functions to be performed by the computer without a huge performance hit.

------------------
Eytee
farpoint@mac.com

Quote

Originally posted by Eytee:
**But couldn't Quartz/Quartz Extreme be used here to increase performance? Seems like Apple created an entire graphics library just to allow such processor intensive image functions to be performed by the computer without a huge performance hit.
**

Actually, Quartz chews the **** out the processor. It wasn't until the advent of Mac OS X 10.2 that the Quartz functions were swapped to the GPU. I don't think that Quartz Extreme will prove to be a useful tool for game developers, but I guess you could ask Andrew what he thinks. 🙂

Dave

------------------
forge
(url="http://"http://www.evula.com")EVula(/url)
(url="http://"http://www.sourcecod.com")sourcecod(/url) for hosting that doesn't suck.