Game Development Community

Selective Area Relight

by Jason Gossiaux · in Torque Game Engine · 10/28/2007 (10:47 pm) · 5 replies

Part of my game design was to have the player place interiors (.DIFs) in a first person view, much like an RTS game. Well, I've got the placing of Interiors down, but cannot figure out how to selectively relight just that building.

I've seen the topic brought up about a dozen times on the forums, and nobody has ever completed their attempt at doing it. Since this is a pretty big deal breaker if I can't get it working, would anyone be able to point me in the right direction? Would there be speed issues with relighting a single interior?

I also saw a post claiming that if an interior used an environmental map that it would be automatically relighted on placement. Does anyone know more about that, I've yet to try it. Thanks in advance for any help you can provide me with!

#1
10/29/2007 (9:27 am)
Well for now I can just compile with GLLighting = true and get fully lit buildings. Unfortunately this looks pretty bad for a release game.

This is definately a complicated problem - I understand why Torque does what it does for performance reasons. But its a problem that makes a majority of game types much harder to develop. It kind of goes hand in hand w/ the Day/Night cycle problem I had asked about below, and to which there isn't many resources explaining.

Does anyone know of a better explaination behind the lighting code? I've snooped through 200 or so lighting functions in the source (all lacking comments... terrible practice on GGs part) and with a group of programmers I could probably make it do what I need. It just seems this is one area that should be better documented.

Ok so brainstorming time. Here's the routes I could see me taking:

1). Use glllighting for now, forget day/night, finish the game and then pay a team to incorporate better lighting for me.

2). Look at the day/night resources again and see if I can convert them to 1.5.2, and if so if they'd fix my problem (doesn't seem like they would). I still don't understand what the people behind the older Day/Night resources were doing under the hood.

3). Investigate a way to turn off pre-lighting completely, and add some new dynamic lighting model. I expect this to have severe performance issues however.

4). Investigate how they do a filtered relight, which supposedly relights JUST what is being rendered at that moment. Then backwards engineer it to work on a set of coords.

5). Check out the Enviromap thing - but I suspect this just turns on GLLighting for that interior.

6). Store 4 pre-lit interiors per interior (heard of people doing this with terrains) and swapping them in/out as time progresses. This looks like my best bet but I've zero idea where to begin hehe.

Ahh well, I never expected quite these kinds of problems. A lack of experience on my part no doubt.
#2
11/01/2007 (3:00 am)
Most of the documentation focus was on the class members used to add lighting to custom objects. Originally the system (TLK) was designed to be a black-box, self contained - objects and data go in and lighting comes out.

There are definitely ways to force the system to relight specific interiors without affecting other objects, however it will definitely take a lot of work (right now area relighting, called filtered relighting, nukes the light maps of all other objects).

Another concern is the lag time of relighting an interior in-game. A few second relight would be annoying enough - if the interior is complex the relight could take significantly longer.

I would say your best bet is #1. Don't worry about it yet, instead get a prototype working that proves the gameplay then worry about how to work out the relighting and interior complexity -vs- relight time issues.
#3
11/04/2007 (8:04 am)
Alright so my single-object relighting is working. I rewrote the relighting interiors to relight only the object ID given. The problem is how the system nukes all other interior relights. I cannot find the code that does this. I've commented out just about anything that looks like it might be deleting the old interior lightmaps to no avail. Any help would be extremely appreciated.

In the release compile relighting a building of moderate size only seems to take .2 seconds. With some further optimization I'm sure this can be reduced even more. Even if not, that is a small price to pay one time when dynamically creating a new interior. I'm almost there!
#4
11/06/2007 (1:14 pm)
Is it absolutely necessary to use Interior files? This would all be much simpler with DTS shapes.
#5
11/06/2007 (4:24 pm)
Yeah it is, the idea is you'll build buildings then be able to go inside of them, decorate them, etc. DTS shapes just wouldn't let me do what I wanted.

Anyways, I've rewritten the engine to relight interiors as I place them. I have also added a periodic relight that isn't noticeable at all in release compile. Relighting an interior seems to take about 250ms, probably less once I optimize the code some. So as long as I schedule them out over a period of say, 5 minutes, nobody will be the wiser. As long as the day passes slow enough you'll not notice the transition too much. And if you do, tough :P

My BIG BIG BIG problem right now is getting the sun to move from script or console. I started another thread on it but nobody has responded yet. Interiors and shapes all move when I edit their position variable, but not the sun object. Its so odd. Almost like I need to call an update method or something that isn't described anywhere...