Page 1 of 1

Light Sources?

Posted: 01 Jun 2007, 03:30
by Argh
Can we create, destroy, and manipulate a point-source of light, using the LUA interface tools? If so, how?

Posted: 01 Jun 2007, 04:32
by Snipawolf
*Drools..*

Hehehe, I hope so...

If I can run it on my 6600, and my 3200+ single core, everybody else can, too.. :twisted:

Posted: 01 Jun 2007, 04:57
by AF
You'd have to implement light mapping via lua to do that. The necessary shaders and openGL calls to do it appear to be in place but I have never implemented it before so ask trepan or jelmer.

Posted: 01 Jun 2007, 11:59
by Warlord Zsinj
If this were possible, would it be limited for large single lightsources, such as having a moving sun or perhaps multiple suns (tattooine? ;) ), or would it be something that could be used (perhaps it's a lightsource with a decay?) for dynamic lighting on explosions, muzzleflashes, etc?

Posted: 01 Jun 2007, 21:00
by AF
Imagine turning shadow mapping on and off, and the performance difference.

Then, factor in a 5-10% performance decrease for lua speed and inexperience.

Then place 1 extra light point other than the sun.

You now have 2 shadow maps to handle and a lightmap.

Add a third light point.

2 lightmaps, and 3 shadowmaps.

Now imagine that this was implemented per map. It wasnt in settings.exe. Imagine the user outrage.

Stuff like dynamic lighting is not something that people should implement in lua using the tools currently provided. Its possible, and you could probably get away with a few tricks here and there rather than full dynamic lighting. But the lighting effects would need to be mod absed not map based save for features, I'm thinking street lamps on dark maps, light houses, fires.

Posted: 02 Jun 2007, 00:28
by AlfaSub
AF, it wouldn't be too hard to add a setting like "MAX # of shadowmaps" to the settings dialog. Then it would be user-configurable. The only thing that concerns me is if this many shadowmaps would be too large of a performance hit to create a good coolness/performance ratio.

Posted: 02 Jun 2007, 11:39
by jcnossen
This kind of lighting requires knowledge of the light when drawing all stuff.. so it's basically impossible without touching all the drawing code. TBH it should be done in C++ if done at all, you want to be able to quickly check which lights are worth enabling etc..

Posted: 02 Jun 2007, 17:24
by Dragon45
btw argh, are you trying todo some funky dnyamic light stuff? (explosion effects, on-unit lights, etc?

Posted: 03 Jun 2007, 02:04
by rattle
Snipawolf wrote:If I can run it on my 6600, and my 3200+ single core, I'm gonna spend some dollars so everybody else can too.

Posted: 03 Jun 2007, 02:10
by AF
chance of it not running on that rig if implemented in lua:

99%

Posted: 03 Jun 2007, 22:04
by Argh
Is it just me, or every time I start to talk about ideas here, it becomes an irrelevant argument :roll:

Ok, so JC, you're saying "don't do this, you fool, because it would all have to be routed through all the drawing calls, and doing it through LUA would take too darn long". Good enough. I figured that was the answer, because of the way that the map formats are all tied into the rendering system, but I wanted to be sure. TBH, I didn't really know where I was going with this, because custom GroundFlashes and other nifty things are in the next Spring anyhow, and I don't think I'll actually need it.

Posted: 03 Jun 2007, 23:18
by jcnossen
I'm saying it can't be done, with lua all you can do is draw more things, not change existing drawing code (such as map rendering).