View Full Version : my lighting system for Duke 3D
DeeperThought
01-18-2008, 02:50 AM
Here is a new movie showing Kaiser's new light stick (flare) model and my lighting system. In this vid the light is in line of sight mode, which means it can cast shadows (depending on how the sectors are arranged) and only goes where it is unobstructed (at least in theory).
http://www1.picturepush.com/photo/a/363839/movie/363839.wmv
I have pretty much given up on making this effect compatible with the various hardcoded lighting effects, which means it is buggy in normal maps (it sometimes overrides the lighting created by light switches, etc.). However, I plan to extend the system so it could replace most of the hardcoded effects, so a mod that used this would work smoothly. I will include it with Duke Plus as an option for people to play with.
oak man
01-18-2008, 07:32 AM
Wow! Thats amazing!
Usurper
01-18-2008, 01:18 PM
Pretty slick effect.
0815Jack
01-18-2008, 03:59 PM
well i think this a good start....
replacing the hardcoded effects might be better than making them compatible....
is there lag between triggering the effect and the execution?
could the effect be more soften....i mean.... no sharp shadow borders....or would this mean to remove the entire hardcoded stuff?
but all in all very nice done.... i am waiting to see more :)
xeroxt4
01-18-2008, 04:39 PM
... well, its not real time soft shadows with hight dynamic range and parallax bump mapping, but it is an improvement. :D
DeeperThought
01-18-2008, 06:03 PM
well i think this a good start....
replacing the hardcoded effects might be better than making them compatible....
I will try to make most of them compatible anyway.
is there lag between triggering the effect and the execution?
There is, but the lag can be reduced or eliminated at the cost of performance. I may make it user adjustable.
could the effect be more soften....i mean.... no sharp shadow borders....?
No. In the BUILD engine, lighting is done by shading walls, floors, ceilings, and sprites. Walls and sectors have sharp borders. Also, sectors come in various shapes and sizes. This necessarily limits the effect in various ways.
Remember that this is purely an exercise in scripting using the existing game engine -- it does not enhance the game engine in any way.
Mr.Fibbles
01-18-2008, 06:53 PM
That last scene with the "door opens, room lights up" was pretty neat. To do that normally requires some sector effects and such.
Sobek
01-18-2008, 07:36 PM
That's amazing DT... The first thing I thought when I saw the blocky, monochromatic nature of the lighting was 'Artsy'. I can only imagine how awesome this could look for someone working on a Cell-Shaded looking mod.
I'm curious, can that flare be placed on a moving sector and actually move around, still lighting things up? I'd have some very interesting ideas for it if that were possible.
Fantastic work, keep pushing the envelope ;)
DeeperThought
01-18-2008, 10:43 PM
I'm curious, can that flare be placed on a moving sector and actually move around, still lighting things up?
Yes. And any sprite in the game can be a light source, not just the flares. Monsters, projectiles, headlights on a train, etc.
0815Jack
01-19-2008, 04:45 AM
No. In the BUILD engine, lighting is done by shading walls, floors, ceilings, and sprites. Walls and sectors have sharp borders. Also, sectors come in various shapes and sizes. This necessarily limits the effect in various ways.
Remember that this is purely an exercise in scripting using the existing game engine -- it does not enhance the game engine in any way.
i see now....but the effect is still nice :)
foleyben
01-19-2008, 08:11 AM
How long before this is available to the public?
Awesome effects btw. Any chance of adding colors? maybe even making it flicker?
Devan
01-19-2008, 02:32 PM
Wow, it's perfect! Or maybe "almost perfect", but I like that :)
DeeperThought
01-19-2008, 08:34 PM
How long before this is available to the public?
Not long. I've improved the effect about as much as I know how, so now I'm focusing on optimization and adding hooks so mappers and players can incorporate it into the game.
Awesome effects btw. Any chance of adding colors? maybe even making it flicker?
These user adjustable defines should give you some idea of the current options:
define LIGHT_BRIGHTNESS 60 // 60 is about the brightness of a good torch
define LIGHT_COLOR 0 // same effect as wall pals; most do nothing; 1=blue, 2=red, etc.
define LIGHT_FLICKER 0 // 0=no flicker, 100=completely random intensity between 0 and brightness value
define LIGHT_MODE 2
// LIGHTMODES -- the higher the light mode, the more realism and worse performance
// 0 = Shading determined by distance and light intensity only (light can go through walls)
// 1 = Adds a visibility check to midpoint of sector; if sector cannot see the light, the effect of that light is reduced
// 2 = Adds visibility checks from several points in the sector; if all the checks fail, then the light has no effect on that sector
// 3 = Calculates light distance and visibility relative to each wall separately -- extremely CPU intensive
define LIGHT_LAG 4 // raising this improves performance but adds delay to light effects
xeroxt4
01-19-2008, 11:11 PM
... can't wait... can this be - like - put in - like - maphacks, into - like - existing maps?
DeeperThought
01-20-2008, 01:24 AM
... can't wait... can this be - like - put in - like - maphacks, into - like - existing maps?
It already works in existing maps, because it doesn't require that anything be placed in the maps.
But it isn't really that great in existing maps, because they already have enough lighting. I mean, it's fun to lob a flare into the darkened movie theater in E1L1 and light it up, but it doesn't serve any useful purpose, so the novelty wears off pretty quickly. What the effect calls for is maps that are designed with it in mind. I think it also needs to have some effects on gameplay. By the way, you do realize that it will be part of Duke Plus, right?
Spiker
01-20-2008, 01:53 AM
By the way, you do realize that it will be part of Duke Plus, right?
Yes we do but it's weird why it wasn't posted in Duke Plus, Maybe because new threads attract more visitors;)
BTW have you found any misakes in my screen or is the text ok? Probably i dont mean spelling mistakes but I wonder if it sounds good and if i have chosen proper words for that.
I also wanted to announce something. You people of this forum listen to me, to your preacher. Duke Plus is the best mod you can play, or maybe not mod but it's the best Duke3d can give to you, there's no comparison between This and the original game, and every day it's even better. Play, work and map for Duke Plus.
gorath
01-20-2008, 11:26 AM
Considering it's still made by con coding it's definately a jaw droppin' act! Can't wait for the next release. :)
Maruno
01-20-2008, 01:39 PM
Can we get some pictures showing each of the light modes? Just to see what each one's doing.
DeeperThought
01-21-2008, 03:09 AM
Can we get some pictures showing each of the light modes? Just to see what each one's doing.
Yes, sooner or later.
I think I am just about done making the lighting effect compatible with the hardcoded effects. It was a bitch. Take the CYCLER, for example. If a sector has a CYCLER in it, you cannot change any of the shade values on the walls, floor or ceiling. You just can't change them, because the game is constantly doing it with its hardcoded effect and it overrides you. So, the sectors with cyclers would be totally unaffected by the flares. To fix this, here's what I had to do: 1. When the map loads, I replace the CYCLER sprites with different sprites. 2. When the actors which control my lighting effect (sector controllers) are initialized, they find the replacement sprites in the same sector and read the values off them (the GPSPEED values are already set on these), 3. When the game starts, the sector controllers then emulate the effect of the CYCLERS, using the values they read. It's not a perfect emulation, but it's close and it's smoother. 4. The sector controllers also have to calculate the effect of the flares and other dynamic lights and apply them correctly (which was the whole point of replacing the hardcoded CYCLERs).
The Commander
01-21-2008, 03:27 AM
Yes, sooner or later.
I think I am just about done making the lighting effect compatible with the hardcoded effects. "And Bla bla bla bla computer talk"
DT, Have you ever considered becoming a full time computer/game developer/programmer? LOL :D
Mblackwell
01-22-2008, 01:06 AM
I hate to be the one that kind of rains on people's parades, but while it looks cool, this effect (which I showed DeeperThought a version of that I cooked up awhile ago) along with somewhat similar effects (http://mb.mirage.org/duke/dynamic.gif) (like a bloom effect I cooked up) look cool but aren't really practical.
In this case the impracticality comes in the fact that the effect depends entirely on how the map is made. In most circumstances in fact it will look terrible, and the only way to get nice looking lighting across everything is to break up sectors into smaller squares or (even better) triangulations. This doesn't work well with general map building. Obviously you could make a map with the effect in mind, but it's going to be limited.
DukePatso
01-22-2008, 01:32 AM
Very nice work. And I can't agree that it's not practical.
DeeperThought
01-22-2008, 02:20 AM
I hate to be the one that kind of rains on people's parades, but while it looks cool, this effect (which I showed DeeperThought a version of that I cooked up awhile ago) along with somewhat similar effects (http://mb.mirage.org/duke/dynamic.gif) (like a bloom effect I cooked up) look cool but aren't really practical.
In this case the impracticality comes in the fact that the effect depends entirely on how the map is made. In most circumstances in fact it will look terrible, and the only way to get nice looking lighting across everything is to break up sectors into smaller squares or (even better) triangulations. This doesn't work well with general map building. Obviously you could make a map with the effect in mind, but it's going to be limited.
Some people might read your first paragraph and get the impression that my effect is based on yours. Of course you know it isn't. I wasn't even aware of the lighting effects you had done until I had already coded most of mine, and I have never seen your code.
As for how practical it is, and how terrible it looks, perhaps you have higher standards than I do. The main purpose of this effect is to give the player the ability to light dark areas so he can see better. It does that, and I think it looks okay in most maps.
Anyway, it's time for another movie!
http://www4.picturepush.com/photo/a/369847/movie/369847.wmv
Notice that in the first part of the E1L1 clip, the flare is placed outside of the door, and sure enough, only the wall that can be "seen" by the flare actually gets lit. That was really the purpose of giving the light a line of sight mode. The shadows that you see generated in that funky map with all the square sectors are not something that would happen in a normal map, but it was a side-effect of the line of sight feature.
Mblackwell
01-22-2008, 10:40 AM
No they're not based on each other. My point was that things like this don't tend to get used a lot due to how practical (or unpractical) they are. And that it doesn't really look at all accurate unless the map is designed for it.
Rider
01-22-2008, 12:53 PM
Descent did something fun with lighting. Instead of 1 lightvalue per 'face', it had 1 in each corner of every face. Through this, you could have some relatively accurate lighting effects without having something as complex as lightmaps.
Additionally, this could be made compatible with existing maps REALLY simple-like and still offer support for more advanced types of lighting :)
Could that be something useful?
Roma Loom
01-22-2008, 01:56 PM
Sounds like vertex colour system...
xeroxt4
01-22-2008, 05:09 PM
I like it, a definite improvement... although, the white light bloom 2D Sprite Thing Around The Flare should vary with distance. And anyone else think that having such light blooms applied to other things as well would make the game look better... like in UT99,
http://www.mmplayer.hu/a_kepek/ut/face.jpg
>.<
DeeperThought
01-22-2008, 05:36 PM
I like it, a definite improvement... although, the white light bloom 2D Sprite Thing Around The Flare should vary with distance. And anyone else think that having such light blooms applied to other things as well would make the game look better... like in UT99,
http://www.mmplayer.hu/a_kepek/ut/face.jpg
>.<
Originally I had it varying with distance, but I decided to make its size determined by the strength of the light. That way you can tell when the flare is running out. When you spawn it, it is actually getting stronger for a few moments, which is why it grows. I think I'm going to tone it down a bit, though.
There's already a bloom effect in Duke Plus, by the way, but the blooming lights have to be placed in maps. There's at least one sample map that uses them if you want to download it from my sig. They aren't that great, though. UT it's not.
xeroxt4
01-22-2008, 07:42 PM
Aww... manual placement... (T_T) ... I think that they are pretty cool.
Usurper
01-22-2008, 09:23 PM
My initial reaction to the first movie was similar to what Mb posted, untiil I realized the value of the system for, as he said, maps designed with it in mind. If I were modding with Duke Plus, I'd forgo the flare, personally, but I'd love to use the same effect in situations in which I can plan the architecture accordingly. That, and just having sprite/model lights to shoot out instead of sector-based light surfaces alone is a cool addition.
DeeperThought
01-22-2008, 10:31 PM
My initial reaction to the first movie was similar to what Mb posted, untiil I realized the value of the system for, as he said, maps designed with it in mind. If I were modding with Duke Plus, I'd forgo the flare, personally, but I'd love to use the same effect in situations in which I can plan the architecture accordingly. That, and just having sprite/model lights to shoot out instead of sector-based light surfaces alone is a cool addition.
You can do the destrucible lights effect right now, as of the latest Duke Plus:
Place a red D sprite (tile 2943) where you want the light to be. Give it a lotag of 1. Give it a hitag corresponding to the picnum that you want it to become when the map loads (for example, if you give it a hitag of 2000, then it will be a PIGCOP that is also a light source). Next, in 2D mode, press F8 on the sprite to edit its other properties. Set the YVEL of the sprite to the intensity that you want the light to be (values between 30 and 200 are good for most purposes). Finally, set the ZVEL of the sprite if you want the light to flicker (1-100). The size and pal of the sprite will be preserved when it changes picnum.
The flares are an optinal feature which are off default, but I think they will make a good addition if people map with them in mind. They are meant to be strategic. Imagine a cavern so dark that you literally can't see where you are going without a light. Now add deadly pits and subterranean monsters. You can't shoot or mantle while holding a flare, so you have to spawn one and then place it or throw it in a good location while you do your jumping and fighting. A dropped/thrown flare can be picked up again, but they burn out after a while. Right now it's set up so that there is a certain number that can exist in the map at one time, and you can keep spawning them up to that number. But I could easily change this to make them a regular item with a finite supply. I could also add light triggered effects or devices for more gameply gimmickry.
Tea Monster
01-23-2008, 02:31 PM
Monsters seeing a flare and coming to get you - you'd hear the sound of it approaching in the darkness before you saw it... :D
Mr. Pink
01-24-2008, 12:13 PM
Man, this looks great! Time to become a mapper.
Tea Monster
01-24-2008, 01:10 PM
Is the glare around the flare part of the model or is it an engine effect?
DeeperThought
01-24-2008, 02:04 PM
Is the glare around the flare part of the model or is it an engine effect?
It's neither. It's just a sprite that sticks to the model. The size of the sprite changes with the intensity of the light. It has been toned down since those movies were posted, btw. Of course, you can always just download the latest version of Duke Plus and see for yourself :D
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.