Dynamic DX Lighting

Community Forums/Showcase/Dynamic DX Lighting

Rob Farley(Posted 2003) [#1]
I was just having a play about with lights.

I created a Maplet level and recorded where the lights are using Droplet. Then I wrote a bit of code to see where the lights are (in relation to the player) pick the one closest to the player and put a DX light there of the right colour.

It works pretty well apart from the fact that you can be lit by a light on the other side of a wall... Bah details!

[img "http://mysite.freeserve.com/mentalillusion/temp/b001.jpg"]
[img "http://mysite.freeserve.com/mentalillusion/temp/b002.jpg"]
[img "http://mysite.freeserve.com/mentalillusion/temp/b003.jpg"]
[img "http://mysite.freeserve.com/mentalillusion/temp/b004.jpg"]


Anthony Flack(Posted 2003) [#2]
Cool - regarding the lighting through walls, I'm no 3d guru or nuthin, but couldn't you do a linepick or summat, at the point when the target light was chosen? (wouldn't have to be every frame)


Rob Farley(Posted 2003) [#3]
Yes you could, this was just a quick-and-dirty-see-how-it-looks affair, if I were to implement this into a game I'd do a linepick or summat, probably summat as droplet deals with zones too, so if the light is in the same zone at the player then use it type thing.


Beaker(Posted 2003) [#4]
Stonking. It actually gives more logic to the way a location looks. That red room would look very odd without the lady (bathed in red light) standing in it.

Stating the obvious I know, but certainly drives it home graphically.


Binary_Moon(Posted 2003) [#5]
You're working on this again then Rob? Doesn't look like a spooky mansion anymore.

I notice you've retextured her... in fact... she's got a bum - I thought the skirt looked good.

Here's what I have so far (my version of the buffy texture) I work on it on and off so she's taking her time :)



BTW I think you still have that seam down her middle. Just move the chest uv coords that are next to the edge of the texture right three or four pixels. That will sort it all out.


Rob Farley(Posted 2003) [#6]
Ben, totally retextured from scratch (apart from the head) did my own UVs the lot! I've been playing with unwrapping meshes as it's something I've got to learn to do, after that got to play with animation.

The poly count has gone up a bit due to the arse, but still sub 1000 tris. I thought the skirt just made her look like a hooker! And totally not an adventuring kick-ass kind of look.

Not sure if I'm working on this or not though, I just had a thought about lights and thought I'd give it a go, it turned out pretty good (at least I think so), the level is just something I'd done playing around with maplet ages ago.

My main project is Lander, although I've also got a little puzzle game on the production line called 'All Aboard'. Oh, and droplet, oh, and some other stuff too...


jhocking(Posted 2003) [#7]
This looks like a useful trick. In order to match the player's coloring to the lightmap I am actually checking the color of lightmap pixels under the player; there are definite pros and cons to either mine or your method.


Mustang(Posted 2003) [#8]
The poly count has gone up a bit due to the arse


...Sounds like she's getting fat? :)

Anyways, this kind of light / lightmap blending is the only way to make lightmapped enviroments and realtime lighted characters match. This technique was used for example in the Max Payne, more or less.

I suggested ages ago a method where I would use cubemap lighting the same way as it would result smoother and better lighting (color gradients) and has direction too (from the enviroment to the character), so it's way better than plain point light. But Blitz3D still has no cubemap support so I can't do that at least for now.


Zo Zo Zee Zar(Posted 2003) [#9]
I'm checking the color of the lightmap underneath my player and all characters too. Robs method looks just as good though although if you have 5 lights in a room with 4 baddies and the player it may fall down.


Red Ocktober(Posted 2003) [#10]
Nice looking models guys...

Doc, is the handrails and supporting crossmembers in the second picture all geometry, or is it done with alpha transparencies?

--Mike


Rob Farley(Posted 2003) [#11]
Robs method looks just as good though although if you have 5 lights in a room with 4 baddies and the player it may fall down.
How so? it checks for the 2 nearest lights to the player and puts DX lights there, also I've just added an extra bit of code that dims them as you move further away (kind of like fall off).

[quote]Doc, is the handrails and supporting crossmembers in the second picture all geometry, or is it done with alpha transparencies?[quote]It's geometry.


semar(Posted 2003) [#12]
@Rob,
nice idea indeed.

A question, since I would like to implement the same concept:
How can you pick the right colour that the light should have ? Do you pick a vertex color under the (droplet's) light coordinates ? If so, how ?

By the way, I find Droplet extremely useful, and I'm using it in my project - thanks a lot for such an useful application.

Regards,
Sergio.


semar(Posted 2003) [#13]
Sorry, double post.


Zo Zo Zee Zar(Posted 2003) [#14]
How so? it checks for the 2 nearest lights to the player and puts DX lights there, also I've just added an extra bit of code that dims them as you move further away (kind of like fall off).


Just thinking of things you may come up against, what I meant in my example is the nearest two lights to the player may not be the nearest light to baddie number one - infact all baddies may be nearer to other lights - means the dx light count is going to go up and potentially run out - depends on how many lights you are going to have in a room i guess.

It might be worth you trying the lightmap method too to see the difference - the shots you postest above certainly look amazing, im just thinking dx lights go through other objects, so, if your character walks in and out of a nice shadow casting from a pillar or something she wont react to that shadow - picking the lightmap pixel beneath her would give you this tho.

Another example would be where you have an iron grating in the roof with light shining through it like this:

(excuse the crude image but i just knocked it up quick to demonstrate), if you pick the lightmap underneath the character she will walk in and out of the shadows being cast giving a really cool effect and making her really look like she is there, using a dx light will light her correctly and from the right angle but wont allow her to walk in and out of the shadows.


Rob Farley(Posted 2003) [#15]
Good point Dave... A combination of the 2 is in order I think. Pick up the colour from the lightmap and the location in the same way. I'm using a 2 DX lights the whole time and it's totally driven from the player location. Sure bad guys might look a bit odd now and again but I'm not worrying too much about it.

Sergio, I just set up a light entity in droplet with RGB values (you have to manually enter it all), then just read it in. Or indeed create a bunch of light entities of different (common) colours, ie Red light, Green light, Cyan light etc.


Zo Zo Zee Zar(Posted 2003) [#16]
Yeah like it - combination of the two will look awesome, two lights will be nice and fast and yes i agree - the odd bad guy looking odd wont detract from the overall cool lighting. Nice one :)


semar(Posted 2003) [#17]
Cheers Dr Av for explanation, and thanks all for such an interesting discussion.

:)

Sergio.


DarkEagle(Posted 2003) [#18]
can you explain the theory/code of reading the pixels under the player? i assume a linepick, then find the uv coords? any chance of telling me how?


DJWoodgate(Posted 2003) [#19]
Someone posted some code a while back. Its in one of the 3d forums. Anyway the tricky bit is getting the picked UV coords, because Blitz does not have a pickedU/pickedV function. Once you have the UV coords its easy to get the appropriate pixel from the lightmap texture. Fortunately Fredborg has mastered the maths, done all the hard work, and has posted this code in the archives. http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=515.